pWnd711 Posted June 27, 2020 Share Posted June 27, 2020 Hey Guys i have a question. I draw a Picture and its possible to zoom into the image? Thanks to all Link to comment Share on other sites More sharing options...
UEZ Posted June 27, 2020 Share Posted June 27, 2020 3 hours ago, pWnd711 said: I draw a Picture and its possible to zoom into the image? Yes, it is. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
pWnd711 Posted June 27, 2020 Author Share Posted June 27, 2020 Can you explain me? Link to comment Share on other sites More sharing options...
UEZ Posted June 27, 2020 Share Posted June 27, 2020 Here an example code which you can analyze. There are more ways to zoom an image, this is one of them: #include <GDIPlus.au3> #include <GUIConstantsEx.au3> Global $sImage = FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.bmp;*.gif;*.tif)") If @error Then Exit MsgBox(16, "Error", "No file selected!", 10) Global $fZoom = 2.5 _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sImage) Global $aDim = _GDIPlus_ImageGetDimension($hImage) Global $hGUI = GUICreate("GDI+ Image Zoom", $aDim[0], $aDim[1]) GUISetState() Global $hCanvas = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsSetInterpolationMode($hCanvas, $GDIP_INTERPOLATIONMODE_NearestNeighbor) _GDIPlus_GraphicsDrawImageRectRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1], _ ($aDim[0] - $aDim[0] * $fZoom) / 2, ($aDim[1] - $aDim[1] * $fZoom) / 2, _ $aDim[0] * $fZoom, $aDim[1] * $fZoom) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() It will zoom the image by factor 2.5 and center the display. Dan_555 and pWnd711 2 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
pWnd711 Posted July 7, 2020 Author Share Posted July 7, 2020 Yes this freeze the Image but i want to zoom in with mouse scrolling and hold right mouse button to navigate on the image 🙂 Can you explain too? I have seen this method already but its freeze the image but i want to move the image to see the rest of the image to by holding rmb and move it y Link to comment Share on other sites More sharing options...
UEZ Posted July 7, 2020 Share Posted July 7, 2020 (edited) This is an old script which I coded a while ago. expandcollapse popup#include <GUIConstantsEx.au3> #include <Misc.au3> #include <Screencapture.au3> #include <WindowsConstants.au3> Global $sx, $z = 10, $sy, $mc2, $f, $scroll_x, $scroll_y Global Const $gdip_x = 0, $gdip_y = 0, $zmin = 5, $zmax = 15, $bg_c = "404040" Global Const $gdip_w = 800, $gdip_h = 600 Global $bW = $gdip_w, $bH = $gdip_h Global Const $hGUI = GUICreate("GDI+ Test", $gdip_w, $gdip_h) GUISetState() Global Const $dll = DllOpen("user32.dll") _GDIPlus_Startup() Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBuffer_Bmp = _GDIPlus_BitmapCreateFromGraphics($gdip_w, $gdip_h, $hGraphic) Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBuffer_Bmp) _GDIPlus_GraphicsSetPixelOffsetMode($hContext, 2) ;~ _GDIPlus_GraphicsSetCompositingQuality($hContext, 2) _GDIPlus_GraphicsSetInterpolationMode($hContext, 5) Global $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $gdip_w / 2, $gdip_h / 2) Global Const $hHBitmap = _ScreenCapture_Capture("", 0, 0, $gdip_w, $gdip_h) Global Const $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) Draw2Graphic($hBmp) Zoom(2) GUIRegisterMsg($WM_MOUSEWHEEL, "_Mousewheel") Do $mc2 = MouseGetPos() While _IsPressed("01", $dll) $mc3 = MouseGetPos() If $mc2[0] <> $mc3[0] Or $mc2[1] <> $mc3[1] Then $scroll_x = ($sx + ($mc3[0] - $mc2[0]) / ($z ^ 2 / 32)) $scroll_y = ($sy + ($mc3[1] - $mc2[1]) / ($z ^ 2 / 32)) Draw2Graphic($hBmp) Zoom(2) EndIf Sleep(10) WEnd $sx = $scroll_x $sy = $scroll_y Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_MatrixDispose($hMatrix) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBuffer_Bmp) _GDIPlus_BitmapDispose($hBmp) _GDIPlus_Shutdown() GUIDelete() DllClose($dll) Exit Func Draw2Graphic($hImage) Local $w, $h _GDIPlus_GraphicsClear($hContext, "0xFF" & $bg_c) If $bW <= $gdip_w And $bH <= $gdip_h Then $f = 1 _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, $gdip_w / 2 - $bW / 2 - $scroll_x, $gdip_h / 2 - $bH / 2 - $scroll_y, $bW, $bH) Else If $bW >= $bH Then $f = $bW / $gdip_w Else $f = $bH / $gdip_h EndIf $w = Floor($bW / $f) $h = Floor($bH / $f) If $w > $gdip_w Then $f = $bW / $gdip_w ElseIf $h > $gdip_h Then $f = $bH / $gdip_h EndIf _GDIPlus_GraphicsDrawImageRect($hContext, $hImage, $gdip_w / 2 - $w / 2 - $scroll_x, $gdip_h / 2 - $h / 2 - $scroll_y, $w, $h) EndIf EndFunc ;==>Draw2Graphic Func Zoom($zoom_dir) Switch $zoom_dir Case -1 _GDIPlus_MatrixDispose($hMatrix) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $gdip_w / 2, $gdip_h / 2) _GDIPlus_MatrixScale($hMatrix, 1 / $f, 1 / $f) $scroll_x = 0 $scroll_y = 0 Case 0 If $z > $zmin Then _GDIPlus_MatrixScale($hMatrix, 0.95, 0.95) $z -= 0.05 EndIf Case 1 If $z <= $zmax Then _GDIPlus_MatrixScale($hMatrix, 1.05, 1.05) $z += 0.05 EndIf Case 2 _GDIPlus_MatrixScale($hMatrix, 1, 1) EndSwitch _GDIPlus_GraphicsSetTransform($hContext, $hMatrix) _GDIPlus_GraphicsClear($hContext, "0xFF" & $bg_c) ;~ _GDIPlus_GraphicsDrawImage($hContext, $hBmp, -$bW / 2 + $scroll_x, -$bH / 2 + $scroll_y) _GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, -$bW / 2 + $scroll_x, -$bH / 2 + $scroll_y, $gdip_w, $gdip_h) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBuffer_Bmp, $gdip_x, $gdip_y, $gdip_w, $gdip_h) EndFunc ;==>Zoom Func _Mousewheel($hWnd, $iMsg, $wParam, $lParam) Switch $wParam Case 0xFF880000 ;mouse wheel up Zoom(0) Return 0 Case 0x00780000 Zoom(1) Return 0 EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_Mousewheel Zoom with mouse wheel, move picture around by pressing the lmb and moving mouse. Edited July 7, 2020 by UEZ DinFuv, Dan_555 and pWnd711 3 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
pWnd711 Posted July 14, 2020 Author Share Posted July 14, 2020 perfect thanks to you! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now