#include <GDIPlus.au3>
$sInPic = '原图.jpg'
$sOutPic = '截取区域.jpg'
_ImageRectToFile($sInPic, 0, 0, 192, 150, $sOutPic)
ShellExecute($sOutPic)
Func _ImageRectToFile($sInPic, $iSrcX, $iSrcY, $iSrcW, $iSrcH, $sOutPic, $iDstX = 0, $iDstY = 0, $iDstW = $iSrcW, $iDstH = $iSrcH)
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sInPic)
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)
$hImage1 = _GDIPlus_BitmapCreateFromGraphics($iDstW, $iDstH, $hGraphics)
$hGraphics1 = _GDIPlus_ImageGetGraphicsContext($hImage1)
_GDIPlus_GraphicsDrawImageRectRect($hGraphics1, $hImage, $iSrcX, $iSrcY, $iSrcW, $iSrcH, $iDstX, $iDstY, $iDstW, $iDstH)
_GDIPlus_ImageSaveToFile($hImage1, $sOutPic)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_GraphicsDispose($hGraphics1)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_Shutdown()
EndFunc ;==>_ImageRectToFile
|