Solved

Need solution for three items...

Posted on 2004-09-01
9
184 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
Comment Utility
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
Comment Utility
0
 

Author Comment

by:DanDaemon
Comment Utility
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
Comment Utility
0
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

 
LVL 4

Expert Comment

by:Evarest
Comment Utility
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
Comment Utility
Hello Evarest,

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

Thanks,
Dan
0
 

Author Comment

by:DanDaemon
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

10 Experts available now in Live!

Get 1:1 Help Now