LB Booster
« Displaying animated GIFs with LBB? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:04am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Displaying animated GIFs with LBB?  (Read 815 times)
Harbinger
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 2
xx Re: Displaying animated GIFs with LBB?
« Reply #5 on: Oct 23rd, 2016, 04:30am »

OK now we're talkin'! It worked on most GIFs, but a few of them weren't displaying correctly. I will narrow down what the difference to see if I can find out why the problem is there...

Now in order to integrate this code into my own program, I need to know what everything does. Can you over-comment the same code, and explain what we're doing with each line (or at least the important ones)? You said we have a lot more flexibility, so i'd like to know what I can exploit to give the user more options.
For my purposes, for example, all GIFs will be DISPLAYED at 25 frames per second. But i'd like to be able to alert the user what the GIVEN framerate is, for the GIF in the preview. Can that be determined? (We'll go with the starting fps since that can be different within each frame.)

Also i'm trying to figure out a way to show the transparency color (index= 0, rgb= "000000") for my bitmaps by recoloring that hue in each frame. Any ideas for GIFs? None of the GIFs or bitmaps have an alpha channel...

Other than those questions, the thing worked like a charm, but I just need to know what does what... cool
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Displaying animated GIFs with LBB?
« Reply #6 on: Oct 23rd, 2016, 09:38am »

on Oct 23rd, 2016, 04:30am, Harbinger wrote:
But i'd like to be able to alert the user what the GIVEN framerate is, for the GIF in the preview. Can that be determined?

Yes. The GdipGetPropertyItem API call, with the PropertyTagFrameDelay parameter, retrieves the duration (in centiseconds) for each frame and stores them in the PropItem() array of structures:

Code:
    struct PropItem(MaxFrames), delay as long
        
    calldll #gdiplus, "GdipGetPropertyItem", image.p.struct as ulong, _
        PropertyTagFrameDelay as long, psize.n.struct as long, _
        PropItem(0) as struct, r as void 

There's a 16-byte header that has to be skipped so to find the duration of the first frame you can do:

Code:
duration = PropItem(4).delay.struct 

(my code makes the assumption that the array immediately follows the header, and that's not documented at MSDN so may be unreliable).

Quote:
We'll go with the starting fps since that can be different within each frame.

Generally that makes sense but be careful that there are some animated GIFs in which the first frame is a 'title' and is displayed for a much longer period than the rest. In that case the last frame would be a better guess at the 'normal' rate.

Quote:
Also i'm trying to figure out a way to show the transparency color (index= 0, rgb= "000000") for my bitmaps by recoloring that hue in each frame. Any ideas for GIFs?

That's easy. The GdipDrawImageRectI function doesn't draw transparent regions at all, which is why there is a CLS immediately preceding it in the code. If you replace that CLS with a FILL you can set the color of the 'transparent' regions to anything you like.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls