[SOLVED] How can I save a GIF when using QRCodeGenLib lazarus / 39-Graphics ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-08-25 15:57 Hey Y'all, While trying to help @daragor in the Spanish forum on this post about QR code generation I came across a strange thing. As you can see from the attached code(TestQRCode-v0.3.zip), while using the SaveToStream (Same overloads for SaveToFile but I only realized after I implemented SaveToStream): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrmMain.btnQRCodeGenSaveJPGClick(Sender: TObject);var  QRCode: IQrCode;  QRCodeBMP: TQRCodeGenLibBitmap;  iwQRCode: TFPWriterJPEG;  fsQRCode: TFileStream;begin  QRCode:= TQrCode.EncodeText(    memQRCodeGen.Text,    TQrCode.TEcc.eccLow,    TEncoding.UTF8  );   QRCodeBMP:= QRCode.ToBitmapImage(7,2);  fsQRCode:= TFileStream.Create('QRCodeGen.jpg', fmCreate);  try    iwQRCode:= TFPWriterJPEG.Create;    try      iwQRCode.ProgressiveEncoding:= False;      iwQRCode.CompressionQuality:= 90;      QRCodeBMP.SaveToStream(fsQRCode, iwQRCode);      QRCodeBMP.Free;    finally      iwQRCode.Free;    end;  finally    fsQRCode.Free;  end;end;  You'll notice the we use a TFPWriterBMP, TFPWriterJPEG and a TFPWriterPNG in their respective places. What I found is that there is no Writer associated with the GIF implementation, only a Reader and I'm now wondering how would I go about implementing the "Save to GIF" button that I gave up on? I'm probably missing something since I didn't dig any further into the issue and just superficially looked at the Graphics unit. In other words, I'm asking you guys cuz I'm a bit lazy Many thanks for any info y'all, it will be immensely appreciated!!! Cheers, Gus ---------------------------------------------------------------------- wp · 2021-08-25 16:41 FP-Image does not support writing of gifs - I don't know why. However, an elemental gif writer for fp-image can be found on https://www.gocher.me/FPWriteGIF. In the attachment you can find how this gif writer can be registered so that gif images can be written by the LCL. The demo is a little QR code generator based on the LazBarCodes package. ---------------------------------------------------------------------- winni · 2021-08-25 17:26 Hi! The BGRAbitmapPack supports GIFs and AnimatedGifs. Available through the Online Package Manager. Winni ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-08-25 17:59 Hey WP, As per usual, many thanks WP, you always deliver !!! Quote from: wp on August 25, 2021, 06:41:45 pmFP-Image does not support writing of gifs - I don't know why. However, an elemental gif writer for fp-image can be found on https://www.gocher.me/FPWriteGIF. Thanks, this is awesome. Just needed to change the bit of code that was diffs from your example to the code on the site and all was well. Do you think the lack of a writing implementation of fcl-image is due to licensing stuff? Quote from: wp on August 25, 2021, 06:41:45 pmIn the attachment you can find how this gif writer can be registered so that gif images can be written by the LCL. The demo is a little QR code generator based on the LazBarCodes package. Again, THANKS so VERY MUCH for the example. I'm attaching v0.4 of my example with both the LazBarcode(Your code verbatim) and the QRCodeGen implemented. I need to see if I can use the WriteToCanvas approach you used when I'm using QRCodeGen, since it's not needed in my use of LazBarcode cuz I've opted for the Visual Component. ATM I'm using a Stream as intermediary and it works, but the approach I wanted in the first place was the one you're doing with WriteToCanvas. Many thanks WP, that was awesome!! Cheers, Gus ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-08-25 18:04 Hey Winni, Quote from: winni on August 25, 2021, 07:26:11 pmThe BGRAbitmapPack supports GIFs and AnimatedGifs. Available through the Online Package Manager. Many thanks for this suggestion. I do have this package installed in one or many of my Lazarus installs. I guess it never crossed my mind since I was trying to not have third- party dependencies apart from the QR Code stuff since there's none of that in the Lazarus/FPC source. Well, that went off the window cuz of the lack of writing implementation on fcl-image. WP's solution is awesome and I'll have a gander and see if I can do it better with BGRAbitmap. So, yeah, many, MANY thanks for reminding me of BGRAbitmap Cheers, Gus ---------------------------------------------------------------------- winni · 2021-08-25 18:17 Hi! There might be 2 reasons, why GIF was not implemented in Lazarus: * 256 Colors were already 20 years ago outdated * Until 2004 there was a copyright fight about using GIFs. This lead to the development of PNG, which is more powerfull than GIF. I don't know. Winni ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-08-25 18:39 Hey Winni, Quote from: winni on August 25, 2021, 08:17:35 pmThere might be 2 reasons, why GIF was not implemented in Lazarus: Well, that's the stranger part of it all: It is implemented but you can only LoadFromFile/Stream, not SaveToFile/Stream. But I dunno how the copyright thing was setup and maybe the infringement was only in writing, not reading GIF files. Quote from: winni on August 25, 2021, 08:17:35 pm* 256 Colors were already 20 years ago outdated Hummmm, not the best of explanations, but yeah, you have a point here Quote from: winni on August 25, 2021, 08:17:35 pm* Until 2004 there was a copyright fight about using GIFs. This lead to the development of PNG, which is more powerful than GIF. Yeap, this could be it, but again, why only implement the reading and leave out the writing. That's what's intriguing the most, LOL !! But, hey, many thanks for putting these out, really appreciate it Cheers, Gus ---------------------------------------------------------------------- winni · 2021-08-25 18:53 Quote from: Gustavo 'Gus' Carreno on August 25, 2021, 08:39:22 pmHey Winni, Yeap, this could be it, but again, why only implement the reading and leave out the writing. That's what's intriguing the most, LOL !! Hi  Gus! That is the nonsense with the "electronic" copyright: You are allowed to look football at all those free Web-channels. But it is forbidden to save  a game to your disk. Same with the GIFs before 2004. Copyright was easy when there were only books and photos ... Winni ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-08-26 21:56 Hey Winni, Quote from: winni on August 25, 2021, 08:53:54 pmThat is the nonsense with the "electronic" copyright: You are allowed to look football at all those free Web-channels. But it is forbidden to save  a game to your disk. Same with the GIFs before 2004. Copyright was easy when there were only books and photos ... Yeah, I do get the point you're making and I do agree about the silliness of it all, LOL!! Cheers, Gus