如何在自动中裁剪位图



我在下面有这个代码来打印位图图像,但我不想打印手柄的完整尺寸。是否可以只打印正方形或在打印后裁剪位图图像?我正在使用自动。

这是我第一次发问题,请原谅任何错误。

$hDDC = _WinAPI_GetDC($hWnd)
$hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight)
$hCDC = _WinAPI_CreateCompatibleDC($hDDC)
_WinAPI_SelectObject($hCDC, $hBMP)
DllCall("User32.dll", "int", "PrintWindow", "hwnd", $hWnd, "hwnd", $hCDC, "int", 0)
_WinAPI_DeleteDC($hCDC)
_WinAPI_ReleaseDC($hWnd, $hDDC)
可以使用

_GDIPlus_BitmapCloneArea从位图中获取矩形。

您需要先包含库:

 #include <GDIPlus.au3>

要裁剪:

 $hClone = _GDIPlus_BitmapCloneArea ( $hBitmap, $nLeft, $nTop, $nWidth, $nHeight [, $iFormat = 0x00021808] )

一个稍微有用的例子:
https://www.autoitscript.com/forum/topic/164820-crop-an-image-from-file/

最新更新