Rotates and flips an image
#include <GDIPlus.au3>
_GDIPlus_ImageRotateFlip ( $hImage, $iRotateFlipType )
$hImage | Pointer to an Image object |
$iRotateFlipType | Type of rotation and flip: 0 - No rotation and no flipping (A 180-degree rotation, a horizontal flip and then a vertical flip) 1 - A 90-degree rotation without flipping (A 270-degree rotation, a horizontal flip and then a vertical flip) 2 - A 180-degree rotation without flipping (No rotation, a horizontal flip followed by a vertical flip) 3 - A 270-degree rotation without flipping (A 90-degree rotation, a horizontal flip and then a vertical flip) 4 - No rotation and a horizontal flip (A 180-degree rotation followed by a vertical flip) 5 - A 90-degree rotation followed by a horizontal flip (A 270-degree rotation followed by a vertical flip) 6 - A 180-degree rotation followed by a horizontal flip (No rotation and a vertical flip) 7 - A 270-degree rotation followed by a horizontal flip (A 90-degree rotation followed by a vertical flip) |
Success: | True. |
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3). |
Search GdipImageRotateFlip in MSDN Library.
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WinAPIHObj.au3>
Example()
Func Example()
_GDIPlus_Startup()
Local Const $iW = @DesktopWidth / 2, $iH = @DesktopHeight / 2
Local $hHBmp = _ScreenCapture_Capture("", 0, 0, @DesktopWidth / 2, @DesktopHeight / 2) ;create a GDI bitmap by capturing 1/4 of desktop
Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBmp) ;convert GDI bitmap to GDI+ bitmap
_WinAPI_DeleteObject($hHBmp) ;release GDI bitmap resource because not needed anymore
_GDIPlus_ImageRotateFlip($hBitmap, 1) ;rotate image by 90 degrees without flipping
Local $hGUI = GUICreate("GDI+ test", $iH, $iW, -1, -1) ;create a test gui to display the rotated image
GUISetState(@SW_SHOW)
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) ;display rotated image
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
;cleanup resources
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_Shutdown()
GUIDelete($hGUI)
EndFunc ;==>Example