Author Topic: photo zome in /out  (Read 3077 times)


  • Jr. Member
  • **
  • Posts: 52
photo zome in /out
« on: March 21, 2015, 12:46:24 am »
Hello to all

I have a photo  BUT how can i zome in /out  it by lazarus???do you have a library???

thanks in advane


  • Hero Member
  • *****
  • Posts: 1256
Re: photo zome in /out
« Reply #1 on: March 21, 2015, 01:32:28 am »
Strange - first attempt to reply vanished (like an old oak table..)

Find the "Edit: Alternative with TImage instead of TImgView32:" code in the first answer

If you're new to lazarus/delphi, then this quick intro might be useful (doesn't do zoom - you'll still need to above code for that)
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:
  BOOKS! (Free and otherwise):

Eugene Loza

  • Hero Member
  • *****
  • Posts: 576
Re: photo zome in /out
« Reply #2 on: March 23, 2015, 09:31:51 am »
I'd have done it the following way:

Create a TJPEG and load an image there.
Then create a TImage on the form and use copyrect to copy the loaded image from TJpeg.
Now for the zooming: You need to specify current position (usually the upper right corner) and current zoom level. Based on these you can modify copyrect properties (i.e. which part of TJpeg to copy).
Finally you should redraw the image on mousemove (maybe a workaround should be used to detect if a mouse button was pressed to pan) and onmousewheel which change the parameters given to copyrect.
Apply copyrect each time parameters changed.
Lazarus 1.9 + FPC 3.1.1 Debian Jessie 64 bit.

My Free and Open Source games in Lazarus/FreePascal/CastleGameEngine:
(and some ancient games in Turbo Pascal too)
Sources are here:


TinyPortal © 2005-2018