• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Resize image with mousehandler

Hello,

I want to place a bounding box around an image and resize it.  I would like to put points on the corners to resize with preserved aspect ratio.  Thanks in advance.

-Gabe
0
fibdev
Asked:
fibdev
  • 8
  • 3
1 Solution
 
msa2003Commented:
Maybe, there is something what you need: http://www.serge.dsip.net/downloads/ResizeImage.zip

This sample (Delphi 6) lets user modify image size and aspect ratio by dragging the points in the corners of the image. I had written this specially for you.

Best regards.
0
 
msa2003Commented:
0
 
msa2003Commented:
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fibdevAuthor Commented:
msa2003,

It doesn't compile.  I have Delphi 5 Standard :(  Can't afford to go all the way at this time.
0
 
msa2003Commented:
Ok, I'll tell when I'll remake it for Delphi 5. You still can use *.pas source.
0
 
msa2003Commented:
Or, you may try to remove all files in the project directory except *.dpr, *.dfm and *.pas and compile the project in this state. If the compiler will return errors, place them here.
0
 
msa2003Commented:
OK, here is Delphi 5 source code: http://www.serge.dsip.net/downloads/ImageResize5.zip
0
 
fibdevAuthor Commented:
Thank you msa,

That will do.  It does flicker and I was wondering if there was a way to prevent that.  I'm going to go ahead and give you the comment as answer but if you want to fallow up I'd appreciate it.

Thanks
0
 
msa2003Commented:
It does flicker because of usage of TImage component and Repaint method. You may decrease flicker effect but the program will be much more complex.
0
 
fibdevAuthor Commented:
Thanks
0
 
msa2003Commented:
No thanks. It is really complex to avoid flicker. The good way is to use double buffering. But as I noted before, this way is complex enough. You should use a memory bitmap (TBitmap is good for it) and paint stretched image on it's canvas (TBitmap.Canvas.StretchDraw). Then, you should paint this bitmap on the form's canvas (TForm.Canvas.Draw). This way doesn't let you use visual components such as TImage to represent pictures.
Another way is simpler and used by early versions of Windows GUI. You may drag the contour of the image and paint the image only when mouse button is released. Use Form.Canvas.FrameRect to draw, repaint and to hide contour.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 8
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now