Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Animated gif and transparent background
Message
From
26/03/2010 03:56:39
 
 
To
26/03/2010 00:37:49
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01456409
Message ID:
01457378
Views:
44
Lim

>>
>>Download thelinked file, extract it and read the readme.txt
>>
>>http://www.multiupload.com/W173RVUQWG
>>
>>(if the download has not yet appeared, try again later as multi upload mirrors the file and this may take some time.)
>
>
>Hi Bernard,
>
>A thousand thanks to you! I will give GDI+x a try.

Don't forget to download the sample class from the link above
>
>Btw, I have 2 quick questions before I really dig in and try,
>1) Is GDI+x classes try to manipulate the GIF as a file or I will have to extract all images that compose the GIF and manipulate them to create the animation effect?

No. There is no need to extract the images. GDI+X will manage the image itself.

>2) Can GDI+x classes resize and display an animated GIF on-the-fly? (I mean not to create another GIF file in different dimension but to display its animation in diff size with the same ratio)

You can do this in any ratio you want, bigger or smaller does not matter. The class can do that easily. Here's how you do it.
Open the class from the download above and open its DRAW method:
LPARAMETERS toSource as xfcImage, toArgs

IF VARTYPE(m.toSource) = "O"
	This.Clear()
	** Update the GIF frame
	This.IA.UpdateFrames(m.toSource)
	** Draw the image on the canvas
	This.oGfx.DrawImage(m.toSource, 0,0)
ENDIF

DODEFAULT()
This is the line that actually "draws" the image. The DrawImage method can also be called like this:

This.oGfx.DrawImage(toSource, Left,Top,Width,Height) and a whole heap more parameters since this is overloaded.

For you the simplest is to change the class like this:
This.oGfx.DrawImage(m.toSource, 0,0,This.Width,This.Height)
Now you can size the control to any size you want and the GIF will be animated to that size.
Also if you set the Anchor ptoperty to 15 then it will resize when you resize the form. GDI+X is really great.

These are valid commands you can use:
This.oGfx.DrawImage(m.toSource, 0,0)  && original size

This.oGfx.DrawImage(m.toSource, 0,0,20,20)  && will animate the GIF 20x20 pixels in size

This.oGfx.DrawImage(m.toSource, 0,0,100,100)  && will animate the GIF100x100 pixels in size
Note that you will need to make sure the imgCanvas object - the class - is resized large enough.

To resize with the same ratio, you need to look at the original ratio and then use that by multiplying the W and H by your factor. The GDI+x samples has a sample form showing how to get the dimensions as well as other info from a gif.

>
>Currently, I solve the problem by placing a round (opaque) background in the GIF itself, so that animation always take place (in my case the red bands of the GIF image that rotate) within the area of this round solid background. This of course is not a perfect solution.

No. GDI+x is the way to go, In fact that is what is used internally in VFP to display the GIF except the implementation leaves a lot to be desired.

If you decide learning how to use the GDI+x classes, my blog has heaps of samples. Also Cesar's blog

http://weblogs.foxite.com/bernardbout
http://weblogs.foxite.com/vfpimaging

Bernard
Previous
Reply
Map
View

Click here to load this message in the networking platform