TFPReaderJPEG to TBitmap lazarus / 39-Graphics ---------------------------------------------------------------------- domasz · 2024-03-24 12:40 I want to use TFPReaderJPEG and store the image in TBitmap 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 Laz: TLazIntfImage;    Reader: TFPReaderJPEG;    Bmp: TBitmap;begin  Reader := TFPReaderJPEG.Create;  Laz := TLazIntfImage.Create(0,0);   Bmp := TBitmap.Create;   try    Laz.LoadFromFile('test\jpg.jpg', Reader);    Bmp.LoadFromIntfImage(Laz); //error here   finally    Reader.Free;    Laz.Free;  end;   Bmp.SaveToFile('test\duddududud.bmp');  Bmp.Free; The above gives error "Failed to create handles". How to do that correctly? ---------------------------------------------------------------------- AlexTP · 2024-03-24 12:43 Sorry but you misplaced QUOTE forum tag instead of CODE forum tag... ---------------------------------------------------------------------- domasz · 2024-03-24 12:50 Thank you, Alex! ---------------------------------------------------------------------- paweld · 2024-03-24 13:22 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  Laz: TLazIntfImage;  Reader: TFPReaderJPEG;  Bmp: TBitmap;begin  Reader := TFPReaderJPEG.Create;  Bmp := TBitmap.Create;                Laz := Bmp.CreateIntfImage;  try    Laz.LoadFromFile('d:\tapeta.jpg', Reader);    Bmp.LoadFromIntfImage(Laz);   finally    Reader.Free;    Laz.Free;  end;   Bmp.SaveToFile('d:\duddududud.bmp');  Bmp.Free;end; ---------------------------------------------------------------------- wp · 2024-03-24 13:44 Or: 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 uses  FPImage, FPReadJPEG, FPWriteBMP; procedure TForm1.Button2Click(Sender: TObject);var  img: TFPCustomImage;  reader: TFPReaderJPEG;  writer: TFPWriterBMP;begin  img := TFPMemoryImage.Create(1, 1);  reader := TFPReaderJPEG.Create;  writer := TFPWriterBMP.Create;  try    img.LoadFromFile('test\jpg.jpg', reader);    img.SaveToFile('test.bmp', writer);  finally    img.Free;    writer.Free;    reader.Free;  end;end; // or even shorter, when standard settings are sufficient:procedure TForm1.Button2Click(Sender: TObject);var  img: TFPCustomImage;begin  img := TFPMemoryImage.Create(1, 1);  try    img.LoadFromFile('test\jpg.jpg');    img.SaveToFile('test.bmp');  finally    img.Free;  end;end; ---------------------------------------------------------------------- domasz · 2024-03-24 13:53 Thank you, paweld and wp! ---------------------------------------------------------------------- lainz · 2024-03-24 14:19 With BGRABitmap: 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 uses BGRABitmap; var  bgra: TBGRABitmap;begin  bgra := TBGRABitmap.Create('file.jpg');  bgra.SaveToFile('file.bmp');  bgra.Free;end; ---------------------------------------------------------------------- wp · 2024-03-24 17:53 I was trying to compare binary sizes, and found that I can compile the BGRABitmap code only when I add the LCL to the requirements of this little project ("error: undefined symbol, WSRegister(many classes)", and this blows up the exe size to 2.88 MB (Win 11). The pure fcl-image code in my post, however, has only 300 kB. Is there a way to run BGRABitmap without needing the LCL? ---------------------------------------------------------------------- lainz · 2024-03-25 01:18 Quote from: wp on March 24, 2024, 06:53:39 pmI was trying to compare binary sizes, and found that I can compile the BGRABitmap code only when I add the LCL to the requirements of this little project ("error: undefined symbol, WSRegister(many classes)", and this blows up the exe size to 2.88 MB (Win 11). The pure fcl-image code in my post, however, has only 300 kB. Is there a way to run BGRABitmap without needing the LCL? Yes is possible search for BGRABitmap Core. In th forums and in github. ---------------------------------------------------------------------- domasz · 2024-03-25 08:27 Quote from: lainz on March 24, 2024, 03:19:28 pmWith BGRABitmap: 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 uses BGRABitmap; var  bgra: TBGRABitmap;begin  bgra := TBGRABitmap.Create('file.jpg');  bgra.SaveToFile('file.bmp');  bgra.Free;end; BGRABitmap is great but I wanted to see what could be done with the built-in decoders. ---------------------------------------------------------------------- wp · 2024-03-25 09:36 Quote from: lainz on March 25, 2024, 02:18:13 amYes is possible search for BGRABitmap Core. In th forums and in github. Thanks. I updated my BGRABitmap repo, copied the bgrabitmap folder into the project directory and added the define BGRABITMAP_CORE in the project options. This made the project (your code a few posts higher) compile without adding LCL. Now the exe size (after stripping debugger symbols) is 952 kBytes (compared to 297 kBytes for the fcl-image version). ---------------------------------------------------------------------- lainz · 2024-03-25 12:27 Quote from: wp on March 25, 2024, 10:36:51 amQuote from: lainz on March 25, 2024, 02:18:13 amYes is possible search for BGRABitmap Core. In th forums and in github. Thanks. I updated my BGRABitmap repo, copied the bgrabitmap folder into the project directory and added the define BGRABITMAP_CORE in the project options. This made the project (your code a few posts higher) compile without adding LCL. Now the exe size (after stripping debugger symbols) is 952 kBytes (compared to 297 kBytes for the fcl-image version). Yes, is very low in both cases. Less than 1mb. Streaming a movie nowadays is like 4gb or more in HD. I don't know in 4k.