Waubot Posted June 27, 2014 Share Posted June 27, 2014 These example files work, but when the window placed under another window, then brought to the front again, the image is blank / white. http://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_ImageResize.htm http://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_BitmapCreateFromHBITMAP.htm Does the window have to be refreshed all the time, or is this some kind of graphical issue on my system? Link to comment Share on other sites More sharing options...
junkew Posted June 27, 2014 Share Posted June 27, 2014 case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Waubot Posted June 27, 2014 Author Share Posted June 27, 2014 Thanks for the quick response. This works if the window is minimized and restored, it does not work when another window is over it temporarily. expandcollapse popup#include <GUIConstantsEx.au3> #include <ScreenCapture.au3> Example() Func Example() _GDIPlus_Startup() Local Const $iW = @DesktopWidth, $iH = @DesktopHeight Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH) ;create a GDI bitmap by capturing full screen of the desktop Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore Local $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap, $iW / 4, $iH / 4) ;resize image Local $hGUI = GUICreate("GDI+ test", $iW / 4, $iH / 4, -1, -1) ;create a test gui to display the resized image GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Scaled) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Tekk Posted June 27, 2014 Share Posted June 27, 2014 (edited) I think you're looking for the WM_PAINT event. expandcollapse popup#include <GUIConstantsEx.au3> #include <ScreenCapture.au3> #include <WindowsConstants.au3> Global $hGraphics, $hBitmap_Scaled ;~ <<<<<<< Example() Func Example() _GDIPlus_Startup() Local Const $iW = @DesktopWidth, $iH = @DesktopHeight Local $hHBmp = _ScreenCapture_Capture("", 0, 0, $iW, $iH) ;create a GDI bitmap by capturing full screen of the desktop $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap _WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore $hBitmap_Scaled = _GDIPlus_ImageResize($hBitmap, $iW / 4, $iH / 4) ;resize image Local $hGUI = GUICreate("GDI+ test", $iW / 4, $iH / 4, -1, -1) ;create a test gui to display the resized image GUIRegisterMsg($WM_PAINT, "WM_PAINT") ;~ <<<<<<< GUISetState(@SW_SHOW) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) ;display scaled image EndSwitch WEnd ;cleanup resources _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hBitmap_Scaled) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Example Func WM_PAINT($hWnd, $iMsgm, $wParam, $lParam) ;~ <<<<<<< #forceref $hWnd, $iMsgm, $wParam, $lParam _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Scaled, 0, 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_PAINT Edited June 27, 2014 by Tekk Link to comment Share on other sites More sharing options...
Waubot Posted June 28, 2014 Author Share Posted June 28, 2014 That did it, thanks 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