Solved

Need solution for three items...

Posted on 2004-09-01
9
185 Views
Last Modified: 2010-04-05
Hello All,

Can somebody provide me some example to implement next items for working with TImage:
1. Select and move area on TImage, like Microsoft Paint;
2. Enter and show text like Microsoft Paint.

Thanks you very much if you can help!

NEED ASAP.

Thanks,
Dan Daemon.

P.S. Need sample code, not ideas.
0
Comment
Question by:DanDaemon
  • 5
  • 4
9 Comments
 
LVL 4

Expert Comment

by:Evarest
ID: 11953944
This might help you further. It's about drawing a line and selecting it. The same principle should work with your project...

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20718897.html

Evarest
0
 
LVL 4

Accepted Solution

by:
Evarest earned 500 total points
ID: 11954091
0
 

Author Comment

by:DanDaemon
ID: 11954110
Thanks Evarest,

Good example, but I do not need to do it with objects....

I just need to select some area on TImage and move it to another point...
Like MS Paint functions...

Thanks,
Dan
0
 
LVL 4

Expert Comment

by:Evarest
ID: 11954136
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:Evarest
ID: 11954180
Objects you say...

Well, that might proove a bit more difficult, and quite impossible to put into a simple post over here... This requires quite a lot of coding. You might be interested in components like Graphics32 (http://g32.org), but actually even this one doesn't offer the "simple" option to draw such a selection box.

I don't have such code at hand, but maybe other experts do...

Kind regards,
Evarest
0
 

Author Comment

by:DanDaemon
ID: 11954193
Hello Evarest,

Please wait, I think some of them is very good example, just need to check...

Thanks,
Dan
0
 

Author Comment

by:DanDaemon
ID: 11954314
Hello Evarest,

Thank you, very good examples...

It is not clones of MS Paint functions but this examples will help me...

Thanks,
Dan
0
 

Author Comment

by:DanDaemon
ID: 11954344
Evarest,

Also, I need to move some part of TImage as bitmap...
Probably you know some examples?

Thanks.
0
 
LVL 4

Expert Comment

by:Evarest
ID: 11955318
Maybe the following complete library of components can be interesting for you. Sadly it costs $50 to purchase it (no source)

http://plsoft.users.btopenworld.com/html/components.html

To select a part of your bitmap, you can use the following component:

http://swiss.torry.net/vcl/graphics/other/trectbox.zip

Just install it as you usually do. You will have to make a few changes to the source code to make it work properly, though:

Open RectBox.pas and add after line 298 (invalidate; in procedure TRectBox.WMLMouseDown(var Message: TMessage);) inherited;

Do this again in the following procedure.

This way, the component respons to mousedown and up events and you can use the following code:

[BEGIN CODE]

var
 BmpBuff: TBitmap;

procedure TForm1.RectBox1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 BmpBuff.Width :=RectBox1.Width;
 BmpBuff.Height :=RectBox1.Height;
 BitBlt( BmpBuff.Canvas.Handle,
         0,
         0,
         RectBox1.Width,
         RectBox1.Height,
         Image1.Picture.Bitmap.Canvas.Handle,
         RectBox1.Left,
         RectBox1.Top,
         SRCCOPY );
end;

procedure TForm1.RectBox1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
 aRect, SrcRect: TRect;
begin
 aRect :=Rect( RectBox1.Left,
               RectBox1.Top,
               RectBox1.Left+RectBox1.Width,
               RectBox1.Top+RectBox1.Height );
 SrcRect :=Rect( 0, 0, BmpBuff.Width, BmpBuff.Height );
 Image1.Picture.Bitmap.Canvas.CopyRect(aRect, BmpBuff.Canvas, SrcRect);
end;

initialization
 BmpBuff :=TBitmap.Create;

finalization
 BmpBuff.Free;

[END CODE]

Just place a TImage on the form and the TRectBox. Load a TBitmap in the TImage and place the TImage at coords (0,0).

When you move the TRectBox, the underlaying part of the Bitmap will be copied and transposed when you let your mousebutton up.

This is a very rudimentary code, but i'm sure you can change it to make it work just like you want :-)

Kind regards,
Evarest
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filemaker 14 vs Delphi Embarcadero 7 187
Need Delphi function to get Youtube video title 5 228
Delphi Form ownership 4 73
Dev express lookupcombo 3 14
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

864 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

21 Experts available now in Live!

Get 1:1 Help Now