Solved

Need solution for three items...

Posted on 2004-09-01
9
187 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Expert Comment

by:Evarest
ID: 11954136
0
 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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