|
-
Aug 27th, 2001, 06:11 AM
#1
Thread Starter
New Member
User Animation to AVI
Hi.... I need to convert a file of this format into AVI.
This is the layout of the file
=================================
Public Type ActorFileHeader
a1 As Integer
a2 As Long
a3 As Long
a4 As Long
End Type
Public Type ACTORINFO
dwStructSize As Long
dwImageCount As Long
dwImageWidth As Long
dwImageHeight As Long
dwBitCount As Long
dwControlFlags As Long
End Type
Public Type ARGB
Blue As Byte
Green As Byte
Red As Byte
Alpha As Byte
End Type
the file looks like this:
Public Actheader As ActorFileHeader
Public ActInfo As ACTORINFO
Public m_membits() as ARGB ' series of bytes that make up image
======================================
Any code on how to do this???
I need to convert this bitmap data first into a DIB so i can put it into AVI. Any API Code that would let me convert my bitmap into a dib?
Thanks in advance. Help is greatly appreciated!
-
Aug 27th, 2001, 11:55 AM
#2
Frenzied Member
A DIB is just a BMP if I'm not wrong. You can use direct memory access (there's an article on that at Unlimited Realities: http://www.ur.co.nz/ ) to read the RGB values from the array and put them on a bitmap, then make an AVI out of it. But you won't be able to use alpha in it
-
Aug 27th, 2001, 07:25 PM
#3
Thread Starter
New Member
Thanks for the info!
BTW. I visitied your dx effects thread and I noticed you wanted to put it in a dll... i found this tutorial on the net that teaches you to create a dll in vc++ then use it in vb
its in http://www.allapi.net/vbtutor/vcdll1.php
Anyways, i cant seem to find the tutorial. What's the tutorial name???
-
Aug 28th, 2001, 10:44 AM
#4
Frenzied Member
Thanks, I'll have a look into that (if it doesn't work, since I tried it before with another tutorial and it didn't work, I guess I'll ahve to learn C++ the hard way )
Since I can't fine it too, here it is 
VB Code:
'These are the declarations you need to put before every other sub
Private Type SAFEARRAYBOUND
cElements As Long
lLbound As Long
End Type
Private Type SAFEARRAY1D
cDims As Integer
fFeatures As Integer
cbElements As Long
cLocks As Long
pvData As Long
Bounds(0 To 0) As SAFEARRAYBOUND
End Type
Private Type SAFEARRAY2D
cDims As Integer
fFeatures As Integer
cbElements As Long
cLocks As Long
pvData As Long
Bounds(0 To 1) As SAFEARRAYBOUND
End Type
Private Declare Function VarPtrArray Lib "msvbvm50.dll" Alias "VarPtr" (Ptr() As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
'This will extract an array from the picture property of a picturebox
' these are used to address the pixel using matrices
Dim pict() As Byte
Dim sa As SAFEARRAY2D, bmp As BITMAP
' get bitmap info
GetObjectAPI Pictbox.Picture, Len(bmp), bmp 'dest
' exit if not a supported bitmap
If bmp.bmBitsPixel <> 24 Then
MsgBox " 24-bit bitmaps only", vbCritical
Exit Sub
End If
' have the local matrix point to bitmap pixels
With sa
.cbElements = 1
.cDims = 2
.Bounds(0).lLbound = 0
.Bounds(0).cElements = bmp.bmHeight
.Bounds(1).lLbound = 0
.Bounds(1).cElements = bmp.bmWidthBytes
.pvData = bmp.bmBits
End With
CopyMemory ByVal VarPtrArray(pict), VarPtr(sa), 4
'Here's where you manipulate the array! The RGB values of each pixel are by order in the X, so you'd have to use this:
For Y = 0 to UBound(pict,2)
For X = 0 to UBound(pict,1) Step 3
'This is the red value
pict(X+2,Y) = ...
'The green value
pict(X+1,Y) = ...
'The blue value
pict(X,Y) = ...
Next X
Next Y
'This is necessary, or VB will destroy your array and you'll get errors!
' clear the temporary array descriptor
' without destroying the local temporary array
CopyMemory ByVal VarPtrArray(pict), 0&, 4
If you need help, reply here again!
-
Aug 28th, 2001, 11:03 AM
#5
Good Ol' Platypus
So, uh.. why did you declare a SafeArray1D?
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Aug 28th, 2001, 11:35 AM
#6
-
Aug 29th, 2001, 08:18 AM
#7
Thread Starter
New Member
Thanks for the input guys. I figured the thing out with the help of a friend who knows VC++. It involves use of the APIs createBitmap then supplying the bits to the function.
Safe arrays? never heard of that before. I'll study the above code throughly and the API varptrarray.
BTW the dxeffects looks good!
-
Aug 30th, 2001, 08:51 PM
#8
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|