How to convert from TBGRABitmap to TBitmap? lazarus / 39-Graphics ---------------------------------------------------------------------- domasz · 2023-02-22 11:42 I thought this should work but it just creates a full black image. I know I can do "A.Assign(B);" but I would prefer to keep whatever pixelformat and width/height I have. 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 A: TBitmap;    B: TBGRABitmap;begin  B := TBGRABitmap.Create('test.png');   A := TBitmap.Create;  A.PixelFormat := pf32bit;  A.Width := B.Width;  A.Height := B.Height;    B.Draw(A.Canvas, 0,0);  A.SaveToFile('test.bmp');  A.Free;  B.Free; ---------------------------------------------------------------------- KodeZwerg · 2023-02-22 12:09 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 TForm1.Button1Click(Sender: TObject);var  A: TBitmap;  B: TBGRABitmap;begin  B := TBGRABitmap.Create(ExtractFilePath(ParamStr(0)) + 'KodeZwerg.png');  try    A := TBitmap.Create;    try      A.PixelFormat := pf32bit; // it automatic be whatever your display got, it is bugged      A.Width := B.Width;      A.Height := B.Height;      A.Canvas.CopyMode := cmSrcCopy;      A.Canvas.CopyRect(            Rect(0,                 0,                 A.Width,                 A.Height),            B.Canvas,            Rect(0,                 0,                 B.Width,                 B.Height));      A.SaveToFile(ExtractFilePath(ParamStr(0)) + 'KodeZwerg.bmp');    finally      A.Free;    end;  finally    B.Free;  end;end; Does that fit your needs? ---------------------------------------------------------------------- domasz · 2023-02-22 12:10 Quote from: KodeZwerg on February 22, 2023, 01:09:08 pm Does that fit your needs? Interesting, thank you! ---------------------------------------------------------------------- lainz · 2023-03-21 22:37 The first spammer that uses Chat-GPT? Or just did a search... Casino link. Edit: response is good, moderator please just remove the link... ---------------------------------------------------------------------- KodeZwerg · 2023-03-21 22:52 Quote from: domasz on February 22, 2023, 12:42:18 pmI know I can do "A.Assign(B);" Quote from: Mauger Guillory on March 21, 2023, 11:26:20 pm  bmp.Assign(bgraBmp.Bitmap); Quote from: lainz on March 21, 2023, 11:37:24 pmresponse is good I am curious how this can be good when it was already in original post but please do what you think is best for forum ---------------------------------------------------------------------- lainz · 2023-03-21 23:14 Yes, but keep it is not as bad, at lease shows with actual code how to assign.. You can do this as well: 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 BGRAReplace(bgra, bgra.resample(bitmap.width, bitmap.height)); To resample with high quality the bgrabitmap. Then you can draw it to any canvas: 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 bgra.Draw(bitmap.canvas, 0, 0);