Forum > Graphics
How to convert from TBGRABitmap to TBitmap?
domasz:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
--- Quote from: KodeZwerg on February 22, 2023, 01:09:08 pm ---
Does that fit your needs?
--- End quote ---
Interesting, thank you!
lainz:
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:
--- Quote from: domasz on February 22, 2023, 12:42:18 pm ---I know I can do "A.Assign(B);"
--- End quote ---
--- Quote from: Mauger Guillory on March 21, 2023, 11:26:20 pm --- bmp.Assign(bgraBmp.Bitmap);
--- End quote ---
--- Quote from: lainz on March 21, 2023, 11:37:24 pm ---response is good
--- End quote ---
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 :-*
Navigation
[0] Message Index
[#] Next page