Solved

Select part of a Image

Posted on 1998-11-24
4
158 Views
Last Modified: 2011-09-20
How can I select part of a picture in a Image, say Image1
then cut that part of the image to the clipboard.
0
Comment
Question by:Asw
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
rene100 earned 50 total points
ID: 1347771
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
 
LVL 1

Author Comment

by:Asw
ID: 1347772
Hi Reen100,

Any chance of a snippet of code;

Andy
0
 
LVL 2

Expert Comment

by:rene100
ID: 1347773
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
 
LVL 1

Author Comment

by:Asw
ID: 1347774
Thanks Rene100,

The points are yours
Andy

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now