Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

Select part of a Image

How can I select part of a picture in a Image, say Image1
then cut that part of the image to the clipboard.
0
Asw
Asked:
Asw
  • 2
  • 2
1 Solution
 
rene100Commented:
hi

you can use the tcanvas.copyrect method. As TargetCanvas, you can use a run-time created TImage and copy this with the
TClipboard.assign to the clipboard.

reagards
rene
0
 
AswAuthor Commented:
Hi Reen100,

Any chance of a snippet of code;

Andy
0
 
rene100Commented:
ok, here's the example. As you can see, I use a TBitmpa instead of a second TImage.

uses clipbrd;

procedure TForm1.Button2Click(Sender: TObject);
var
Bitmap: tbitmap;
rect1,rect2: trect;
begin
Bitmap:=tbitmap.create;
rect2.top:=10;  //*Define the area to be copied
rect2.left:=10;
rect2.Right:=100;
rect2.Bottom:=100; //**

//Define where in bitmap the copied part of Image1 should be
rect1.top:=0;
rect1.left:=0;
rect1.Right:=90;
rect1.Bottom:=90;

Bitmap.width:=100; //Very important! if you forget this, it will
Bitmap.height:=100;//it will not work!

Bitmap.Canvas.CopyRect(rect1,image1.canvas,rect2);//Copy to Bmp
clipboard.Assign(Bitmap);//Copy to the clipboard
Bitmap.free;
end;

regards

rene
0
 
AswAuthor Commented:
Thanks Rene100,

The points are yours
Andy

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now