?
Solved

Need solution for three items...

Posted on 2004-09-01
9
Medium Priority
?
194 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 1500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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!

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 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