1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2024-05-12 06:50:12 +00:00
InForm/docs/GIFPlay.md
2024-01-10 05:29:38 +05:30

3.6 KiB

Animated GIF Player Library

By a740g

Usage instructions

You can use the Library either standalone or with InForm-PE.

Standalone

' At the top of your code include GIFPlay.bi
'$INCLUDE:'GIFPlay.bi'

' Your code here...

' At the bottom of your code include GIFPlay.bas
'$INCLUDE:'GIFPlay.bas'

With InForm-PE

Your form must contain a PictureBox control that'll serve as a container for the GIF file you'll load with this library. In the External modules section of the .bas file generated by InForm, $INCLUDE both GIFPlay.bi and GIFPlay.bas. The first must come before the line that includes InForm.ui and the second must come after that, as in the sample below:

': External modules: --------------------------------
'$INCLUDE:'InForm/extensions/GIFPlay.bi'
'$INCLUDE:'InForm/InForm.ui'
'$INCLUDE:'InForm/xp.uitheme'
'$INCLUDE:'gifplaySample.frm'
'$INCLUDE:'InForm/extensions/GIFPlay.bas'

API

FUNCTION GIF_LoadFromFile%% (Id AS LONG, fileName AS STRING)
FUNCTION GIF_LoadFromMemory%% (Id AS LONG, buffer AS STRING)

GIF_LoadFromFile is a function that takes a PictureBox control ID (or any unique ID) and a GIF file name and returns True if loading the animation is successful. GIF_LoadFromMemory does the same. However, it loads the animation from a STRING buffer.

SUB GIF_Free (Id AS LONG)

Frees resources used by the GIF file loaded previously using GIF_LoadFromFile or GIF_LoadFromMemory.

FUNCTION GIF_IsLoaded%% (Id AS LONG)

Returns True if GIF file is completely loaded and ready for use.

FUNCTION GIF_GetWidth~& (Id AS LONG)

Returns the width of the GIF in pixels.

FUNCTION GIF_GetHeight~& (Id AS LONG)

Returns the height of the GIF in pixels.

FUNCTION GIF_GetFrameNumber~& (Id AS LONG)

Returns the number of currently playing frame.

FUNCTION GIF_GetTotalFrames~& (Id AS LONG)

Returns the total number of frames in a loaded GIF. If not an animated GIF, it returns 1.

FUNCTION GIF_IsPlaying%% (Id AS LONG)

Returns True if a GIF is currently being played.

SUB GIF_Play (Id AS LONG)
SUB GIF_Pause (Id AS LONG)
SUB GIF_Stop (Id AS LONG)

Starts, pauses or stops playback of a loaded GIF file.

FUNCTION GIF_GetTotalDuration~&& (Id AS LONG)

Returns the total runtime of the animation in ms.

FUNCTION GIF_GetFrameDuration~&& (Id AS LONG)

Returns the total runtime of the current frame in ms.

FUNCTION GIF_GetElapsedTime~&& (Id AS LONG)

Returns the current runtime of the animation in ms.

SUB GIF_SetLoop (Id AS LONG, loops AS LONG)

Set the looping behavior, where < 0 means play once, 0 means loop forever and +n means loop n times.

SUB GIF_Draw (Id AS LONG)

Draws the current frame on a destination surface @ (0, 0) (stretching the frame if needed). GIF_Draw must be called from within the __UI_BeforeUpdateDisplay event. That's where the frames will be updated in your PictureBox control.

FUNCTION GIF_GetFrame& (Id AS LONG)

Returns the current rendered frame image to be played. Playback is time sensitive so frames may be skipped or the last frame may be returned. Use this if you want to do your own final _PUTIMAGE. Do not free the image. The library will do that when it is no longer needed.

FUNCTION GIF_GetBackgroundColor~& (Id AS LONG)

Returns the background color that should be used to clear the surface before drawing the final rendered frame. Use this if you want to do your own final _PUTIMAGE.

SUB GIF_EnableOverlay (Id AS LONG, isEnabled AS _BYTE)

Hides the GIF overlay image when the GIF is not playing or paused.