Hello Everyone..
I have searched the forum and found many examples for rotating an Image.
I tried to incorporate the same into my script but wasn't able to do so successfully.
I guess my lack of concepts for this area was the reason.
Please could anybody help me find out the problems in my code
I have searched the forum and found many examples for rotating an Image.
I tried to incorporate the same into my script but wasn't able to do so successfully.
I guess my lack of concepts for this area was the reason.
Please could anybody help me find out the problems in my code
[ autoit ]
#include <APIConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> OnAutoItExitRegister("OnAutoItExit") _GDIPlus_Startup() $Form1 = GUICreate("Form1", 593, 453, 193, 115) GUICtrlCreateEdit("Hello There", 10, 10) GUICtrlCreateButton("Get ctl image", 224, 176, 140, 30, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case 4 GetControlBitmap(GUICtrlGetHandle(3), 180) EndSwitch WEnd Func GetControlBitmap($hWnd, $iRotate = 0) $Width = _WinAPI_GetWindowWidth($hWnd) $Height = _WinAPI_GetWindowHeight($hWnd) $hDC = _WinAPI_GetDC($hWnd) $memDC = _WinAPI_CreateCompatibleDC($hDC) $memBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject($memDC, $memBmp) ; use _WinAPI_BitBlt for copying _WinAPI_BitBlt($memDC, 0, 0, $Width, $Height, $hDC, 0, 0, $SRCCOPY) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($memBmp) If $iRotate Then $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixRotate($hMatrix, $iRotate, False) _GDIPlus_GraphicsSetTransform($hGraphics, $hMatrix) ;Again redraw the image so that it turns to 180degree. <<<<<<<<<<<<<<<<<<<<<<< dont know why it doesnt work _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0) ;Lets save and find out what happens _GDIPlus_ImageSaveToFile($hImage, @ScriptDir & '\ctl.bmp') ;.BMP ShellExecute(@ScriptDir & '\ctl.bmp') _GDIPlus_MatrixDispose($hMatrix) _GDIPlus_GraphicsDispose($hGraphics) EndIf _WinAPI_ReleaseDC($hWnd, $hDC) _WinAPI_DeleteDC($memDC) _WinAPI_DeleteObject($memBmp) Return $hImage EndFunc ;==>GetControlBitmap Func OnAutoItExit() _GDIPlus_Shutdown() EndFunc ;==>OnAutoItExit