如何在 AutoIt 中裁剪位图?

How to crop bitmap in AutoIt?

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

第一次发帖提问,如有错误请多多包涵

$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/