Link to home
Create AccountLog in
Avatar of panJames
panJames

asked on

CopyRect- what do I do wrong?

Hello experts :-)

*********************************
I need to do two things.

1. Display a part of Image1
2. Display magnified part of Image1

My failed approaches are:

ad 1.   LImage := TImage.Create(Application);

  LImage.Canvas.CopyMode := cmSrcCopy;
  LImage.Canvas.CopyRect(LRect, MainForm.Image1.Canvas, LRect);


  MainForm.Image1.Picture.Bitmap.Assign(LImage.Picture.Bitmap);
  MainForm.Image1.Refresh;

Result: MainForm.Image1 displays white rectangle only.
        I expected to see empty image with only a LRect part of it displayed in original position.

ad 2.   LImage := TImage.Create(Application);

  LImage.Canvas.CopyMode := cmSrcCopy;
  LImage.Canvas.CopyRect(Rect(0, 0, Round((LRect.Right - LRect.Left) * 4), Round((LRect.Bottom - LRect.Top) * 4)), MainForm.Image1.Canvas, LRect);


  MainForm.Image1.Picture.Bitmap.Assign(LImage.Picture.Bitmap);
  MainForm.Image1.Refresh;

Result: MainForm.Image1 displayes magnified portion of the image but only a part of it.
        I expected to see a the whole magnified LRect portion of Image at 0,0 position.


Question no. 3:

what is the difference between Image1.Picture.Bitmap.Canvas.CopyRect and Image1.Canvas.CopyRect


*********************************

thank u very much

panJames :-)
SOLUTION
Avatar of ThievingSix
ThievingSix
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account