Jump to content
Sign in to follow this  
clearguy

! ZooMa ! Script to zoom on images

Recommended Posts

clearguy

Hi,

Here is my very basic script to zoom on an image.

  • Z to zoom
  • S to unzoom
  • right to move right,left...,up to move up, down to...
Take this image:http://veimages.gsfc.nasa.gov/2429/globe_east_2048.jpg

Rename it to terre.jpg.

Put the script and that image in the same Dir, and let's zoom ;) .

SCRIPT:

; 8--8       888-8-888-88-88            8--8

;88-8-88-888-888-8888-888-888888888888--8888888
;                                             8
;                                             -
;  ZooMa-ZooMa-ZooMa-ZooMa-ZooMa-ZooMa-ZooMa  8
;                                             8
;  Script to zoom on images                   -
;                           by Clearguy       8
;               V.                            -
;                                             8
;88888-88-888-88-88-88-8888-888888-8-8-88-8888

; 8-8-       8-88-8-888-8-88-8            88--


#include <GUIConstants.au3>
$hGUI=GUICreate("Zoomah",500,500)
GUISetState()
Global $CoordGUI2[2]
$CoordGUI2[0]=40
$CoordGUI2[1]=60
Global $Center[2]

$Center[0]=200
$Center[1]=200
$h_cGUI=GUICreate("Child GUI", 400, 400, 40, 60, $WS_CHILD+$WS_HSCROLL+$WS_VSCROLL, $WS_EX_CLIENTEDGE, $hGUI)
$n=GUICtrlCreatePic(@WorkingDir&'\terre.jpg',0,0, 2048,2048)
GUICtrlSetPos($n,0,0,400,400)
GUISetState()
GUISwitch($hGUI)
HotKeySet("z", "zoom")
HotKeySet("s", "unzoom")
HotKeySet("{DOWN}", "down")
HotKeySet("{UP}", "up")
HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
Global $Size=400,$rl=0,$top=0,$ZoomPercent=1.1
Global $x,$X,$y,$Y,$DeltaX,$DeltaY,$Abscisse=0,$Ordonnee=0
    While 1
        $GUIMsg = GUIGetMsg()

        Switch $GUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
Func unzoom()
    $Cursor=GUIGetCursorInfo() 
    $X=$Cursor[0]
    $Y=$Cursor[1]
    
    $x=$X-$CoordGUI2[0]
    $y=$Y-$CoordGUI2[1]
    
    $x=$ZoomPercent*$x
    $z=$ZoomPercent*$y
    
    $DeltaX=$Center[0]-$x
    $DeltaY=$Center[1]-$y
    
    $Size=($ZoomPercent-(2*($ZoomPercent-1)))*$Size
    
    $Abscisse=$Abscisse+$DeltaX
    $Ordonnee=$Ordonnee+$DeltaY
    
    GUICtrlSetPos($n,$Abscisse,$Ordonnee,$Size,$Size)
EndFunc
Func zoom()
    $Cursor=GUIGetCursorInfo() 
    $X=$Cursor[0]
    $Y=$Cursor[1]
    
    $x=$X-$CoordGUI2[0]
    $y=$Y-$CoordGUI2[1]
    
    $x=$ZoomPercent*$x
    $z=$ZoomPercent*$y
    
    $DeltaX=$Center[0]-$x
    $DeltaY=$Center[1]-$y
    
    $Size=$ZoomPercent*$Size
    
    $Abscisse=$Abscisse+$DeltaX
    $Ordonnee=$Ordonnee+$DeltaY
    
    GUICtrlSetPos($n,$Abscisse,$Ordonnee,$Size,$Size)
    
EndFunc

Func down()
    $top=$top-10
    GUICtrlSetPos($n,$rl,$top,$Size,$Size)
EndFunc

Func up()
    $top=$top+10
    GUICtrlSetPos($n,$rl,$top,$Size,$Size)
EndFunc

Func left()
    $rl=$rl+10
    GUICtrlSetPos($n,$rl,$top,$Size,$Size)
EndFunc
Func right()
    $rl=$rl-10
    GUICtrlSetPos($n,$rl,$top,$Size,$Size)
EndFunc

There are some bugs when you zoom to close, don't know why.

By each zoom the image disappear some ms, don't know why too.

Any help to improve is welcome.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Clearguy

Share this post


Link to post
Share on other sites
Michel Claveau

Bonjour !

Chez moi, après un zoom, ou un dé-zoom, l'image disparaît, jusqu'à ce que je la déplace (gauche, droite, haut ou bas).

Edited by Michel Claveau

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.