I have this code below to print a bitmap image, but I don't want to print the full size of the handle. Is it possible to print only a square or crop the bitmap image after print? I am using AutoIt.
This is the first time I posted a question, please forgive any mistakes.
$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)
You can use _GDIPlus_BitmapCloneArea to get a rectangle from a bitmap.
You'll need to include the library first:
#include <GDIPlus.au3>
To crop:
$hClone = _GDIPlus_BitmapCloneArea ( $hBitmap, $nLeft, $nTop, $nWidth, $nHeight [, $iFormat = 0x00021808] )
A slightly useful example:
https://www.autoitscript.com/forum/topic/164820-crop-an-image-from-file/