im working on delphi 7 and I want how to copy / assign the contents of a TpaintBox to Tbitmap?
like this
public { Public declarations } BitMap : TBitmap; end;
I have a Tbitmap declared as open, and I create it onFormCreate like this
procedure TForm1.FormCreate(Sender: TObject); begin BitMap := TBitMap.Create; end;
Then I draw somthing on a bitmap like this
procedure TForm1.DrawOnPainBox; begin If BitMap.Width <> PaintBox1.Width then BitMap.Width := PaintBox1.Width; If BitMap.Height <> PaintBox1.Height then BitMap.Height := PaintBox1.Height; BitMap.Canvas.Rectangle(0,0,random(PaintBox1.Width ),random(PaintBox1.Height)); PaintBox1.Canvas.Draw(0,0,BitMap); end;
using PaintBox1.Canvas.Draw(0,0,BitMap); we can display what is in Bitmap in paintbox, but what is the return path?
How to assign / copy the contents of a field for drawing to a bitmap?
`BitMap:=PaintBox1.Canvas.Brush.Bitmap;`
this will compile, but if I do this and call procedure TForm1.DrawOnPainBox; I get access Violation , and the debugger displays bitmap and PaintBox1.Canvas.Brush.Bitmap , although some lines are drawn on paintBox


source share