?
Solved

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

Posted on 2005-05-14
2
Medium Priority
?
199 Views
Last Modified: 2010-04-05
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;
0
Comment
Question by:olefjeld
2 Comments
 
LVL 5

Accepted Solution

by:
paulb1989 earned 300 total points
ID: 14002505
 zOrgImage := Image1.Picture.Bitmap;

should be

  zOrgImage.Assign(Image1.Picture.Bitmap);
0
 
LVL 1

Author Comment

by:olefjeld
ID: 14002559
Yup,

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

Cheers !
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question