GodlessSinner Posted October 24, 2010 Share Posted October 24, 2010 #include <GUIConstants.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> ; Create GUI $hWnd = GUICreate("GDI+ Example", 500, 500) GUISetState() ; Start GDI+ _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) _GDIPlus_GraphicsClear($hGraphics) ; Take Screenshot at bottom left of screen $hScreenCap_hBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopHeight, @DesktopWidth) $hScreenCap_Bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hScreenCap_hBitmap) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixScale($hMatrix, 0.5, 0.5) _GDIPlus_MatrixRotate($hMatrix, 90, True) _GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix) _ScreenCapture_SaveImage (@DocumentsCommonDir & "\Transform.jpg", _GDIPlus_BitmapCreateFromGraphics(@DesktopHeight, @DesktopWidth, $hGraphics)); this line is wrong _GDIPlus_GraphicsDrawImageRect($hGraphics, $hScreenCap_Bitmap, 0, -400, 500, 500) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _WinAPI_DeleteObject($hScreenCap_hBitmap) _GDIPlus_BitmapDispose($hScreenCap_Bitmap) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Please, help. _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
Malkey Posted October 24, 2010 Share Posted October 24, 2010 Try this. expandcollapse popup#include <GUIConstants.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #Include <GDIPlus.au3> ; Create GUI $hWnd = GUICreate("GDI+ Example", 500, 500) ; Start GDI+ _GDIPlus_Startup() $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics(500, 500, $hGraphics) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) ;_GDIPlus_GraphicsClear($hGraphic) ; Default Clear colour is black. ; Take Screenshot of desktop $hScreenCap_hBitmap = _ScreenCapture_Capture("", 0, 0, @DesktopHeight, @DesktopWidth) $hScreenCap_Bitmap = _GDIPlus_BitmapCreateFromHBITMAP($hScreenCap_hBitmap) GUISetState() ; Placed here so that the AutoIt GUI is not captured. $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixScale($hMatrix, 0.5, 0.5) _GDIPlus_MatrixRotate($hMatrix, 90, True) _GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hScreenCap_Bitmap, 0, -400, 500, 500) _GDIPlus_ImageSaveToFile($hBMPBuff, @ScriptDir & "\Transform.png") Do _GDIPlus_GraphicsDrawImage($hGraphics, $hBMPBuff, 0, 0) Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE ShellExecute(@ScriptDir & "\Transform.png") ; Clean up resources _WinAPI_DeleteObject($hBMPBuff) _WinAPI_DeleteObject($hScreenCap_hBitmap) _GDIPlus_BitmapDispose($hScreenCap_Bitmap) _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Link to comment Share on other sites More sharing options...
GodlessSinner Posted October 24, 2010 Author Share Posted October 24, 2010 (edited) Big thanks, Malkey, however still left one problem - background. How to trim an image, to save only transformation result? Edit: solved. Thanks again:) Edited October 24, 2010 by GodlessSinner _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
UEZ Posted October 24, 2010 Share Posted October 24, 2010 (edited) Malkey was faster Here my version: expandcollapse popup#include <GDIPlus.au3> #include <GUIConstants.au3> #include <ScreenCapture.au3> $width = @DesktopWidth /2 $height = @DesktopHeight / 2 $hHBITMAP = _ScreenCapture_Capture("", 0, 0, $width, $height) $hGUI = GUICreate("GDI+ Example", $width, $height) GUISetState() ; Start GDI+ _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic) $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsClear($hContext) $hBmp = _GDIPlus_BitmapCreateFromHBITMAP($hHBITMAP) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, 0) _GDIPlus_MatrixTranslate($hMatrix, $width / 2, $height / 2) _GDIPlus_MatrixRotate($hMatrix, 90, 0) _GDIPlus_GraphicsSetTransform($hContext, $hMatrix) _GDIPlus_MatrixScale($hMatrix, 0.5, 0.5) _GDIPlus_GraphicsSetTransform($hContext, $hMatrix) _GDIPlus_GraphicsDrawImageRect($hContext, $hBmp, -$width / 2, -$height / 2, $width, $height) Do _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $width, $height) Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Test1.jpg") _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_BitmapDispose($hBmp) _WinAPI_DeleteObject($hHBITMAP) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit Br, UEZ Edited October 24, 2010 by UEZ 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...
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