Recent

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

hamza

  • 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

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
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
http://stackoverflow.com/questions/6049047/graphics32-pan-with-mouse-drag-zoom-to-mouse-cursor-with-mouse-wheel/6050477#6050477

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)
http://lazplanet.blogspot.no/2013/05/a-simple-image-viewer-from-start-to.html
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

Eugene Loza

  • Hero Member
  • *****
  • Posts: 678
    • My games in Pascal
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.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

 

TinyPortal © 2005-2018