Link to home
Start Free TrialLog in
Avatar of olefjeld
olefjeld

asked on

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;
ASKER CERTIFIED SOLUTION
Avatar of paulb1989
paulb1989

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of olefjeld
olefjeld

ASKER

Yup,

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

Cheers !