How to Convert a BMP file into a gif lazarus / 39-Graphics ---------------------------------------------------------------------- Possum · 2019-10-27 02:38 Hi I really though I knew how to do this. I may have years ago in Delphi.. I need to convert a BMP file into a gif file Why does this not work 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 ConvertBMP2GIF;var  bmp: TBitmap;  gif: TGIFImage;begin  gif := TGifImage.Create;  try    bmp := TBitmap.Create;    try      bmp.LoadFromFile('MyBitmap.BMP');      gif.Assign(bmp);    finally    bmp.Free;    end;    gif.SaveToFile('MyBitmap.GIF');  finally    gif.Free;  end;end; I get an exception at the savetofile command but that is due to no file being created.. Any help appreciated.. I want to convert back and forth from gif to bmp and bmp to gif.. Thank You.. ---------------------------------------------------------------------- wp · 2019-10-27 10:03 fcl-image does not provide writing support for gif -- look in folder (fpc)/packages/fcl-image/src: there is a file fpreadgif, but no fpwritegif. I don't know of any Lazarus package which addes gif writing support. You probably must port Anders Melander's/Finn Tolderlund's TGifImage (http://www.tolderlund.eu/delphi/). Or use one of the big imaging libraries such as Vampyre Imaging (http://imaginglib.sourceforge.net/ - works with Laz out of the box) or FreeImage (http://freeimage.sourceforge.net/ - not sure if it works directly with Lazarus) ---------------------------------------------------------------------- lainz · 2019-10-27 13:32 BGRABitmap supports saving gif, see this example code: https://forum.lazarus.freepascal.org/index.php/topic,47062.msg336312.h tml#msg336312 In this case is an animated gif, but I suppose just adding a single frame is enough. 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 var  gif : TBGRAAnimatedGif;  bmp: TBGRABitmap;begin  bmp := TBGRABitmap.Create(100,100,BGRAWhite);  bmp.FontHeight := 30;  bmp.TextRect(Rect(0,0,100,100), 'Hello', taCenter, tlCenter, BGRABlack);   gif := TBGRAAnimatedGif.Create;  gif.SetSize(100,100);  gif.LoopCount:=100;  gif.AddFullFrame(bmp, 500);   bmp.Fill(BGRAWhite);  bmp.TextRect(Rect(0,0,100,100), 'World', taCenter, tlCenter, BGRABlack);   gif.AddFullFrame(bmp, 500);  gif.SaveToFile('image.gif');  gif.Free;   bmp.Free; ---------------------------------------------------------------------- Possum · 2019-10-27 23:36 I didn't know PNG's have a transparent color. So I will use them. Thx Everyone. Maybe I should have asked how to I find out as much as I can about Lazarus and PNG files.. Cheers.. ---------------------------------------------------------------------- winni · 2019-10-28 00:00 Hi There is also animation support for png files called APNG. APNG files are shown by Firefox and Chrome. More about APNG here: http://littlesvr.ca/apng/ Winni