本帖最后由 silvay22 于 2013-5-4 12:44 编辑 ;图片旋转180度
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <winapi.au3>
IMAGE_FZ(@WindowsDir & "\Web\Wallpaper" & "" & "Stonehenge.jpg", @WindowsDir & "\Web\Wallpaper" & "" & "5.jpg")
Func IMAGE_FZ($picpath,$fiename);入口文件,出口文件
$nAngle=180;翻转角度
_GDIPlus_Startup()
$hImage2 = _GDIPlus_ImageLoadFromFile($picpath)
$iW = _GDIPlus_ImageGetWidth($hImage2)
$iH = _GDIPlus_ImageGetHeight($hImage2)
$hWnd = _WinAPI_GetDesktopWindow()
$hDC = _WinAPI_GetDC($hWnd)
$hBMP = _WinAPI_CreateCompatibleBitmap($hDC,$iH,$iW)
_WinAPI_ReleaseDC($hWnd, $hDC)
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP)
$hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1)
$hMatrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixRotate($hMatrix, $nAngle, "False")
_GDIPlus_GraphicsSetTransform($hGraphic, $hMatrix)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0 - $iW , 0-$iH, $iW, $iH)
_GDIPlus_MatrixDispose($hMatrix)
$CLSID = _GDIPlus_EncodersGetCLSID("BMP")
_GDIPlus_ImageSaveToFileEx($hImage1,$fiename, $CLSID)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_ImageDispose($hImage2)
_GDIPlus_GraphicsDispose ($hGraphic)
_WinAPI_DeleteObject($hBMP)
_GDIPlus_Shutdown()
EndFunc
本人将这段由大侠35888894 写的代码,原地址http://www.autoitx.com/forum.php ... hlight=%B7%AD%D7%AA改写成旋转180度的代码,可是改了半天总是图像缺失的很厉害。
就是这一句怎么改都改的不是那么如意 _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage2, 0 - $iW , 0-$iH, $iW, $iH)希望大家能帮帮忙。 |