Forum > Graphics

duplicate tbitmap how?



Apologies my brain is having a non working day :)

How do i duplicate tbitmaps ie bitmap1:=bitmap2 .

I can create the bitmap1, then i can assign it to timage  to make sure it works.

i need to then copy the bitmap1 to bitmap2, and then modify bitmap 2.

i have tried using bitmap2.canvas.copyrect(rect(0,0,width,height),bitmap1,rect(...))
but this does not duplicate the contents,
if i assign bitmap2 to timage2, it is empty.

Any ideas?

its to create a fixed bitmap (bitmap1); which then gets updated/changed in bitmap2 to update a timage, like a buffer


Very simple, step by step:

--- 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.FormClick(Sender: TObject);var bmp1,bmp2 : TBitmap;R : TRect;beginbmp1 := TBitmap.create;bmp1.setsize (200,100);R := Rect(0,0,bmp1.Width,bmp1.height);bmp1.Canvas.Brush.Color := clWhite;bmp1.Canvas.Pen.Color := clRed;bmp1.canvas.FillRect(R);bmp1.canvas.Line(R); bmp2 := TBitmap.create;bmp2.SetSize(200,100);bmp2.Canvas.CopyRect(R,bmp1.Canvas,R); canvas.copyRect (R,bmp2.canvas,R);;;end;

Hi Winni,

Thanks for that,it un froze my brain...  Back on track now.

furious programming:
Also you can use TBitmap.Assign — the result will be the same (exact copy of the source bitmap object).


[0] Message Index

Go to full version