Author Topic: zoom on picture  (Read 3871 times)

0 Members and 1 Guest are viewing this topic.

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
zoom on picture
« on: December 18, 2019, 05:00:16 am »
In your opinion, is there a way to zoom (to display an enlarged area) on a part of an picture ?
Thank you for your ideas on this subject.

Why not yes ?

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: zoom on picture
« Reply #1 on: December 18, 2019, 07:00:50 am »
I've used zooming functions in my vector tracker, but I haven't tried zooming on images. I think that _PUTIMAGE has the necessary parameters to do something like that.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: zoom on picture
« Reply #2 on: December 18, 2019, 08:28:55 am »
Hi. Yes, _PUTIMAGE can this do, also MAPTRIANGLE can do it.

PUTIMAGE example:

Code: QB64: [Select]
  1.  
  2.     PCOPY 1, _DISPLAY
  3.     MX = _MOUSEX: MY = _MOUSEY
  4.     LINE (MX - 100, MY - 100)-(MX + 100, MY + 100), &HFFFFFFFF, B
  5.     '    _PUTIMAGE (MX - 99, MY - 99)-(MX + 99, MY + 99), img, 0, (MX - 50, MY - 50)-(MX + 50, MY + 50) 'zoom 2x
  6.     _PUTIMAGE (MX - 99, MY - 99)-(MX + 99, MY + 99), img, 0, (MX - 25, MY - 25)-(MX + 25, MY + 25) 'zoom 4x
  7.     _DISPLAY
  8.  
  9.  


and MAPTRIANGLE example:

Code: QB64: [Select]
  1.  
  2.     PCOPY 1, _DISPLAY
  3.     MX = _MOUSEX: MY = _MOUSEY
  4.     '     LINE (MX - 100, MY - 100)-(MX + 100, MY + 100), &HFFFFFFFF, B
  5.     '    _PUTIMAGE (MX - 99, MY - 99)-(MX + 99, MY + 99), img, 0, (MX - 50, MY - 50)-(MX + 50, MY + 50) 'zoom 2x
  6.     '    _PUTIMAGE (MX - 99, MY - 99)-(MX + 99, MY + 99), img, 0, (MX - 25, MY - 25)-(MX + 25, MY + 25) 'zoom 4x
  7.  
  8.     CIRCLE (MX, MY), 100, &HFFFFFFFF
  9.  
  10.     FOR circl = 0 TO _PI(2) STEP .02
  11.         dXa = MX + COS(circl) * 99
  12.         dYa = MY + SIN(circl) * 99
  13.  
  14.         dXb = MX + COS(circl + .02) * 99
  15.         dYb = MY + SIN(circl + .02) * 99
  16.  
  17.         dX1 = MX + COS(circl) * 30
  18.         dY1 = MY + SIN(circl) * 30
  19.  
  20.         dX2 = MX + COS(circl + .02) * 30
  21.         dY2 = MY + SIN(circl + .02) * 30
  22.  
  23.         '  zoom ratio is 30:99   ->  1 : 3,3
  24.         _MAPTRIANGLE (MX, MY)-(dX1, dY1)-(dX2, dY2), img TO(MX, MY)-(dXa, dYa)-(dXb, dYb), 0
  25.  
  26.     NEXT
  27.     _DISPLAY
  28.  
  29.  
« Last Edit: December 18, 2019, 08:48:28 am by Petr »

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: zoom on picture
« Reply #3 on: December 18, 2019, 11:58:41 am »

Thank you Petr for your magnifying glass effect. 

Perhaps just I will need to use a square greater then 100 points.

Very nice !



Why not yes ?

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: zoom on picture
« Reply #4 on: December 18, 2019, 12:13:34 pm »

Ok, I tried. It works !!! And you can change the square size too.

But, how to quit the magnifying glass effect and go back to have the normal view of the picture (or the normal screen you had before this zoom effect) ?

Why not yes ?

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: zoom on picture
« Reply #5 on: December 18, 2019, 12:48:40 pm »
Quote
But, how to quit the magnifying glass effect and go back to have the normal view of the picture (or the normal screen you had before this zoom effect) ?



Code: QB64: [Select]
  1. PCOPY _DISPLAY, 1 '    save screen image as image page 1
  2.  
  3. DO UNTIL _KEYHIT = 32 'space for quit from zoom
  4.     PCOPY 1, _DISPLAY
  5.     MX = _MOUSEX: MY = _MOUSEY
  6.     LINE (MX - 100, MY - 100)-(MX + 100, MY + 100), &HFFFFFFFF, B
  7.     '    _PUTIMAGE (MX - 99, MY - 99)-(MX + 99, MY + 99), img, 0, (MX - 50, MY - 50)-(MX + 50, MY + 50) 'zoom 2x
  8.     _PUTIMAGE (MX - 99, MY - 99)-(MX + 99, MY + 99), img, 0, (MX - 25, MY - 25)-(MX + 25, MY + 25) 'zoom 4x
  9.     _DISPLAY
  10.  
  11. PCOPY 1, _DISPLAY 'return saved screen back
  12.