Results 1 to 8 of 8

Thread: User Animation to AVI

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Location
    Manila, Philippines
    Posts
    3

    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!

  2. #2
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Location
    Manila, Philippines
    Posts
    3
    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???

  4. #4
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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:
    1. 'These are the declarations you need to put before every other sub
    2.  
    3. Private Type SAFEARRAYBOUND
    4.     cElements As Long
    5.     lLbound As Long
    6. End Type
    7.  
    8. Private Type SAFEARRAY1D
    9.     cDims As Integer
    10.     fFeatures As Integer
    11.     cbElements As Long
    12.     cLocks As Long
    13.     pvData As Long
    14.     Bounds(0 To 0) As SAFEARRAYBOUND
    15. End Type
    16.  
    17. Private Type SAFEARRAY2D
    18.     cDims As Integer
    19.     fFeatures As Integer
    20.     cbElements As Long
    21.     cLocks As Long
    22.     pvData As Long
    23.     Bounds(0 To 1) As SAFEARRAYBOUND
    24. End Type
    25.  
    26. Private Declare Function VarPtrArray Lib "msvbvm50.dll" Alias "VarPtr" (Ptr() As Any) As Long
    27. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
    28. Private Type BITMAP
    29.     bmType As Long
    30.     bmWidth As Long
    31.     bmHeight As Long
    32.     bmWidthBytes As Long
    33.     bmPlanes As Integer
    34.     bmBitsPixel As Integer
    35.     bmBits As Long
    36. End Type
    37.  
    38. Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
    39.  
    40.  
    41. 'This will extract an array from the picture property of a picturebox
    42.  
    43. ' these are used to address the pixel using matrices
    44. Dim pict() As Byte
    45.  
    46. Dim sa As SAFEARRAY2D, bmp As BITMAP
    47. ' get bitmap info
    48. GetObjectAPI Pictbox.Picture, Len(bmp), bmp 'dest
    49. ' exit if not a supported bitmap
    50. If bmp.bmBitsPixel <> 24 Then
    51.     MsgBox " 24-bit bitmaps only", vbCritical
    52.     Exit Sub
    53. End If
    54.  
    55. ' have the local matrix point to bitmap pixels
    56. With sa
    57.     .cbElements = 1
    58.     .cDims = 2
    59.     .Bounds(0).lLbound = 0
    60.     .Bounds(0).cElements = bmp.bmHeight
    61.     .Bounds(1).lLbound = 0
    62.     .Bounds(1).cElements = bmp.bmWidthBytes
    63.     .pvData = bmp.bmBits
    64. End With
    65. CopyMemory ByVal VarPtrArray(pict), VarPtr(sa), 4
    66.  
    67. '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:
    68.  
    69. For Y = 0 to UBound(pict,2)
    70.   For X = 0 to UBound(pict,1) Step 3
    71.     'This is the red value
    72.     pict(X+2,Y) = ...
    73.     'The green value
    74.     pict(X+1,Y) = ...
    75.     'The blue value
    76.     pict(X,Y) = ...
    77.   Next X
    78. Next Y
    79.  
    80. 'This is necessary, or VB will destroy your array and you'll get errors!
    81.  
    82. ' clear the temporary array descriptor
    83. ' without destroying the local temporary array
    84. CopyMemory ByVal VarPtrArray(pict), 0&, 4

    If you need help, reply here again!
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    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)

  6. #6
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Huh yah, you're right

    It's not my code; I also had to remove an unused BitBlt declaration and lots of unused code
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  7. #7

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Location
    Manila, Philippines
    Posts
    3
    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!

  8. #8
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Thanks!

    SafeArrays is how VB stores YOUR arrays. We use them to cheat VB and be able to translate machine code arrays into VB arrays. That's how we get the bits out of the images

    Here's the entire code where that came from, it also has some effects, but this way you can see how it works. I think it's a lot better to give you the source code than to tell you how to do

    Also note that one of the (2) samples uses an 8-bits image and the other uses 24-bits images
    Attached Files Attached Files
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width