|
|
Anima Giffy is an application that demonstrates the Victor Library multiframe functions.
With this app you can combine individual images into an animation. The screen above
demonstrates loading an existing multiframe animation,
controlling it with start and stop buttons,
and displaying pixel values of an individual frame.
Images can be loaded from BMP, GIF, JPG, PNG, or TIF files. They can also be pasted from the clipboard. The sequence in which the images are loaded determines their sequence in the animation. Frame conditions can be set for each frame:
starting position transparent color Global conditions can be set for the entire animation:
number of times to loop through the animation animation size |
|
|
Download Anima Giffy application and source code. Requires the Victor Library v 5.52 commercial release or eval version.
SaveAnimationFileAs is the most important function in Anima Giffy.
' From Anima Giffy ' Save the animation file Public Sub SaveAnimationFileAs(filename As String) Dim rcode As Long Dim tempimage As imgdes Dim bmh As BITMAPINFOHEADER Dim fileType As String Dim savemode As Long On Error Resume Next Screen.MousePointer = 11 ' Display the hourglass mouse pointer. savemode = 8 ' uncompressed For j = 0 To numframes - 1 ' This application has a global array of the frames. Each frame has an image descriptor. ' If the buffwidth of the image is not zero, the frame is open and it's a valid image and we will save it in the file If (framesarray(j).frameimgdes.buffwidth = 0) then GoTo nextj End If getbmhfromimage bmh, framesarray(j).frameimgdes If (bmh.biBitCount = 24) Then ' If we have a 24-bit image, convert to 8-bit palette color ' because gif only supports up to 8-bit pixel depth Dim colors As Long Dim reduction_mode As Long rcode = allocimage(tempimage, bmh.biWidth, bmh.biHeight, 8) If (rcode = NO_ERROR) Then rcode = standardpalette(tempimage) reduction_mode = CR_TSDDIFF ' For the best image quality rcode = matchcolorimageex(framesarray(j).frameimgdes, tempimage, reduction_mode) If (rcode = NO_ERROR) Then rcode = savegifframe(filename, tempimage, gdata.savedata, fdataarray(j).savedata, savemode) ' Save 8-bit version of original image End If freeimage tempimage ' Release 8-bit version of original image End If Else ' Save the image as is rcode = savegifframe(filename, framesarray(j).frameimgdes, gdata.savedata, fdataarray(j).savedata, savemode) ' Save original image End If If (rcode <> NO_ERROR) Then GoTo done End If nextj: Next j done: Screen.MousePointer = 0 ' Reset the mouse pointer. ' Handle any errors If rcode <> NO_ERROR Then error_handler rcode, filename End If End Sub