Archived

This topic is now archived and is closed to further replies.

.gif with delphi

This topic is 5871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, the image component wont allow me to add a gif file. I was wondering how i can make it so it loads the gif file on a button click. Thx in advance

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok cool i downloaded TGifimage and i was wondering how i can make it so it runs the animation from a button click?? When use this it runs it but not at my command. Thx

Share this post


Link to post
Share on other sites
i don''t know if there is a possibility in the gif component that let you decide if the animation runs or not but :

you can, as an alternative, load the single images of this animation into an imagelist and run the animation by your self.

use a timer that counts from 1 to "imagecount" and changes the shown image to the current step

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
That sounds cool can u give me an example of the code for the timer? Thx

Share this post


Link to post
Share on other sites
the simpliest would be :

var ani_step : integer;

on formcreate you set this to "0";

procedure dxtimertimer;

begin
dxdraw.canvas.fill(0);

dximagelist.items.find (''picname''+inttostr(ani_step)).draw (dxdraw.surface,x,y,0);

dxdraw.flip;

ani_step := ani_step +1;
if ani_step > max_image_count then ani_step := 0;

end;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
For some reason thats throwing up alot of errors....and what do i put for the timer''s event handler???

Share this post


Link to post
Share on other sites
good grief man, thats the code for the timer''s event handler right in front of you - procedure DXTimerTimer...

lhey i tried it and no problems. so check if your timers called "DXTimer" and your imagelists called "DXImageList" and your directDraw thingees called "DXDraw" otherwise its not likely to work.

sorry if i sound a bit patronising, thats not the intention. although people do make silly mistakes like the above.

theropod

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Dude ive sat here and tried 5 different ways its not working

If i gave you the project would u make it flip through so i can see what im doing wrong???

Share this post


Link to post
Share on other sites
please say you DON''T have just copied this example above into your code???
of course it will not work... you have to set your variables, load your images (and change "picname" to your image''s name)
and a procedure does not start with "procedure dxtimertimer;" ....

to theropod : ani_step: integer = 0; <-- thx for the tipp , in fact i did not know that this works :-P i was used to do this in the create procedure so i never looked or asked for other possibilities.

Share this post


Link to post
Share on other sites