Solved

Need solution for three items...

Posted on 2004-09-01
9
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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