Copy an image onto a new form, results in access violation

Hi,

Problem with the following code... I am copying an image from one form to another... If I use showmodal on the form, the access violation do not appear vefore I close the window...
uncommenting the zzommImage code, will result in the excact same problem...

What am I doing wrong ???

procedure TForm1.Image1DblClick(Sender: TObject);
var
  zOrgImage     : TBitmap;
  zZoomMapRect  : TRect;
  //zZoomImage    : TBitmap;
  zWnd          : TForm2;

begin
  zWnd := TForm2.Create(Self);
  zOrgImage := TBitmap.Create;
  //zZoomImage := TBitmap.Create;
  zOrgImage := Image1.Picture.Bitmap;

  zZoomMapRect.TopLeft := Point(100, 100);
  zZoomMapRect.BottomRight := Point(300, 300);

  zWnd.Image1.Picture.Bitmap.Width := zWnd.Image1.Width;
  zWnd.Image1.Picture.Bitmap.Height := zWnd.Image1.Height;

  //zZoomImage.Canvas.CopyRect(Rect(0,0,zWnd.Image1.Width, zWNd.Image1.Height), zOrgImage.Canvas, zZoomMapRect);

  //zWnd.Image1.Picture.Bitmap.Assign(zZoomImage);
  zWnd.Image1.Picture.Bitmap.Canvas.CopyRect(Rect(0,0,zWnd.Image1.Width, zWNd.Image1.Height), zOrgImage.Canvas, zZoomMapRect);

  zWnd.Show;

  //zZoomImage.Free;
  zOrgImage.Free;
end;
LVL 1
olefjeldAsked:
Who is Participating?
 
paulb1989Commented:
 zOrgImage := Image1.Picture.Bitmap;

should be

  zOrgImage.Assign(Image1.Picture.Bitmap);
0
 
olefjeldAuthor Commented:
Yup,

think I went blind from looking at it for too long...

Cheers !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.