Felix. 0 Posted December 22, 2021 Subject says it all. How to create an animated gif from a set of bitmaps? (Firemonkey) Thank you Share this post Link to post
Remy Lebeau 1394 Posted December 22, 2021 AFAIK FireMonkey doesn't support animated GIFs. Use an 3rd party image library that does. Share this post Link to post
Anders Melander 1782 Posted December 22, 2021 1 hour ago, Remy Lebeau said: AFAIK FireMonkey doesn't support animated GIFs. Use an 3rd party image library that does. Doesn't TGIFImage (the non-visual part) work with FireMonkey? Share this post Link to post
Felix. 0 Posted December 23, 2021 5 hours ago, Remy Lebeau said: AFAIK FireMonkey doesn't support animated GIFs. Use an 3rd party image library that does. I don't need to view or play GIFs. I just need to create an animated GIF from a set of bitmaps. Share this post Link to post
Anders Melander 1782 Posted December 23, 2021 5 hours ago, Felix. said: I don't need to view or play GIFs. I just need to create an animated GIF from a set of bitmaps. Try this: procedure MakeGIF(Bitmap1, Bitmap2, Bitmap3: TBitmap); var GIF: TGIFImage; Frame: TGIFFrame; GCExt: TGIFGraphicControlExtension; LoopExt: TGIFAppExtNSLoop; begin GIF := TGIFImage.Create; try Frame := GIF.Add(Bitmap1); // Netscape Loop extension must be the first extension in the first frame! LoopExt := TGIFAppExtNSLoop.Create(Frame); LoopExt.Loops := 0; // Number of loops (0 = forever) // Add Graphic Control Extension GCExt := TGIFGraphicControlExtension.Create(Frame); GCExt.Delay := 30; // Animation delay (30 = 300 mS) Frame := GIF.Add(Bitmap2); GCExt := TGIFGraphicControlExtension.Create(Frame); GCExt.Delay := 30; Frame := GIF.Add(Bitmap3); GCExt := TGIFGraphicControlExtension.Create(Frame); GCExt.Delay := 30; GIF.OptimizeColorMap; GIF.Optimize([ooMerge, ooCrop], rmNone, dmNearest, 0); GIF.SaveToFile('foobar.gif'); finally GIF.Free; end; end; This is just from (my) memory so I'm not sure if it compiles. It's been a while since I wrote that thing. You should be able to find plenty of examples if you search for TGIFImage. Share this post Link to post
Felix. 0 Posted December 23, 2021 2 hours ago, Anders Melander said: Try this: This is just from (my) memory so I'm not sure if it compiles. It's been a while since I wrote that thing. You should be able to find plenty of examples if you search for TGIFImage. Thank you, your memory is great. I'll try it today Share this post Link to post
Remy Lebeau 1394 Posted December 23, 2021 (edited) 17 hours ago, Anders Melander said: Doesn't TGIFImage (the non-visual part) work with FireMonkey? TGIFImage is a VCL class, AFAIK it is not available in FMX. Also, as I don't use FMX myself, my claim about its lack of support for animated GIFs is mainly based on the below post, which presents some 3rd party solutions for displaying animated GIFs in an FMX UI: https://stackoverflow.com/questions/45285599/how-to-use-animated-gif-in-firemonkey For displaying a series of bitmaps in a UI, one can use TBitmapListAnimation, but I don't know if that can also be used to create a GIF. Embarcadero's documentation only mentions that FMX's TBitmap supports GIF on all platforms except iOS, but doesn't mention what kinds of GIFs are supported. Edited December 23, 2021 by Remy Lebeau 1 Share this post Link to post
Anders Melander 1782 Posted December 23, 2021 Ah yes, TGraphic is a VCL class. I forgot that. I don't use FMX either and I knew FMX couldn't use TGIFImage for display (since that requires TPicture/TImage) but I would have thought one could still use the non-visual stuff such as load/save and GIF manipulation. I guess not. Share this post Link to post
Felix. 0 Posted December 26, 2021 On 12/23/2021 at 3:22 AM, Remy Lebeau said: AFAIK FireMonkey doesn't support animated GIFs. Use an 3rd party image library that does. Which one would you recommend for Firemonkey? Share this post Link to post
kabiri 3 Posted January 26, 2023 This question was very old. I had almost the same question, but I didn't want to make a gif file, this vedeo is good Maybe it will help someone. It doesn't work for me. Because I want to know which frame is displayed at any moment. Share this post Link to post
vfbb 285 Posted November 13, 2023 Additional info: On RAD 12 it is possible to encode animated WebP (better format than GIF). See DocWiki. 1 Share this post Link to post
Lars Fosdal 1792 Posted November 13, 2023 Not to forget, FMX+SKIA+LOTTIE files. 1 Share this post Link to post