NassauSky Posted May 16, 2020 Share Posted May 16, 2020 (edited) Hi all, I'm puzzled, I can't seem to get the clip to display twice it's original size. Here is the code I put together: expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <ScreenCapture.au3> Example() Func Example() $x1=0 $y1=0 $x2=100 $y2=100 $w=$x2-$x1 $h=$y2-$y1 GUICreate("Test", 600, 600) $hImagePic=GUICtrlCreatePic("", 10 + 5 , 70 + 5, $w*2, $h*2) ;x,y,w,h GUISetState(@SW_SHOW) _GDIPlus_Startup() ; Initialize GDI+ library $hOrigSS = _GDIPlus_ImageLoadFromFile(@DesktopDir & "\1.jpg") ; Capture 32 bit bitmap and return a bitmap image object $hClip = _GDIPlus_BitmapCloneArea($hOrigSS, $x1, $y1, $w, $h) ;Clip out area of bitmap object; left,top,width,height ;What am I missing? $hResize = _WinAPI_AdjustBitmap ( $hClip, $w*2, $h*2) ;Enlarge width & height $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hResize) ; Create bitmap object from bitmap handle $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($hImagePic)) ; Get the winhandle of the control holding the image and create Graphics Object _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0) ;Paste the picture into the control holding the image _GDIPlus_GraphicsDispose($hGraphic) ; Clean up resources _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hOrigSS) _GDIPlus_Shutdown() ; Shut down GDI+ library While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example Edited May 16, 2020 by NassauSky Link to comment Share on other sites More sharing options...
InnI Posted May 17, 2020 Share Posted May 17, 2020 (edited) ; like this $hClip = _GDIPlus_BitmapCloneArea($hOrigSS, $x1, $y1, $w, $h) ; Clip out area of bitmap object; left,top,width,height $hBMP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hClip) ; Create bitmap handle from bitmap object $hResize = _WinAPI_AdjustBitmap($hBMP, $w*2, $h*2) ; Enlarge width & height $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hResize) ; Create bitmap object from bitmap handle $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($hImagePic)) ; Get the winhandle of the control holding the image and create Graphics Object _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0) ; Paste the picture into the control holding the image ; or like this $hClip = _GDIPlus_BitmapCloneArea($hOrigSS, $x1, $y1, $w, $h) ; Clip out area of bitmap object; left,top,width,height $hResize = _GDIPlus_ImageScale($hClip, 2, 2) ; Enlarge width & height $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($hImagePic)) ; Get the winhandle of the control holding the image and create Graphics Object _GDIPlus_GraphicsDrawImage($hGraphic, $hResize, 0, 0) ; Paste the picture into the control holding the image Edited May 17, 2020 by InnI Link to comment Share on other sites More sharing options...
NassauSky Posted May 17, 2020 Author Share Posted May 17, 2020 Thanks @InnI Better answer than I expected. First you gave 2 solutions and better yet that you marked my comments so I knew what I did wrong. Using my longer way I had to revert it back to a bitmap object from a handle but I do like your 2nd option better. Thanks again! 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