Author |
Topic: Displaying animated GIFs with LBB? (Read 811 times) |
|
Rod
Full Member
member is offline


Gender: 
Posts: 110
|
 |
Re: Displaying animated GIFs with LBB?
« Reply #2 on: Oct 16th, 2016, 7:20pm » |
|
The standard ATL code has been proved to work for .gif files on a variety of systems. So the question is, is this a normal .gif file? or are there PC specific constraints that stop the gif from playing.
So it will be interesting to hear if Gordon's code runs for you.
Share the culprit .gif if not.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Displaying animated GIFs with LBB?
« Reply #3 on: Oct 17th, 2016, 10:27am » |
|
on Oct 16th, 2016, 7:20pm, Rod wrote:| The standard ATL code has been proved to work for .gif files on a variety of systems. |
|
I would expect it to work, but the GDIPlus code is a lot more flexible. Here are some of the things it can do which the ATL control can't:
Since it uses a standard graphics window or graphicbox, you can draw over the GIF, add text to the GIF, save the GIF to a BMP file, scroll the window etc.
You can gather information about the GIF, such as image dimensions, number of frames, duration of each frame etc.
You can control the animation, for example display only some of the frames, or animate it backwards, or animate it at a different speed, or repeat it only a certain number of times etc. Richard.
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline


Gender: 
Posts: 110
|
 |
Re: Displaying animated GIFs with LBB?
« Reply #4 on: Oct 17th, 2016, 12:23pm » |
|
Yes I see it is much more flexible, but the gif should display with the ATL code, so interested to so what Harbinger discovers.
|
|
Logged
|
|
|
|
Harbinger
New Member
member is offline


Gender: 
Posts: 2
|
 |
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...
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
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.
|
|
Logged
|
|
|
|
|