Creates a new device-depended bitmap (DDB) from the source bitmap with new dimensions and color adjustment.
#Include <WinAPIEx.au3>
_WinAPI_AdjustBitmap ( $hBitmap, $iWidth, $iHeight [, $iMode [, $tAdjustment]] )
$hBitmap | A handle to the source bitmap. |
$iWidth | The width of the new bitmap, in pixels. If this parameter is (-1), the width will be the same as in the source bitmap. |
$iHeight | The height of the new bitmap, in pixels. If this parameter is (-1), the height will be the same as in the source bitmap. |
$iMode | [可选参数] The stretching mode. This parameter can be one of the following values. $BLACKONWHITE $COLORONCOLOR $HALFTONE $WHITEONBLACK $STRETCH_ANDSCANS $STRETCH_DELETESCANS $STRETCH_HALFTONE $STRETCH_ORSCANS |
$tAdjustment | [可选参数] $tagCOLORADJUSTMENT structure containing the color adjustment values. This color adjustment is used only if $HALFTONE ($STRETCH_HALFTONE) stretching mode are set. |
Success | A handle to the newly created bitmap (DDB). |
失败: | 返回 0 并设置 @error 标志为非 0 值. |
#Include <APIConstants.au3>
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global Const $STM_SETIMAGE = 0x0172
Global Const $STM_GETIMAGE = 0x0173
Global $hForm, $Pic, $hPic, $tSIZE, $W, $H, $hObj, $hBitmap, $hResize
; Load and resize (x2) image
$hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
$tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
$W = 2 * DllStructGetData($tSIZE, 'X')
$H = 2 * DllStructGetData($tSIZE, 'Y')
$hResize = _WinAPI_AdjustBitmap($hBitmap, $W, $H)
_WinAPI_DeleteObject($hBitmap)
; 创建 GUI
$hForm = GUICreate('MyGUI', $W, $H)
$Pic = GUICtrlCreatePic('', 0, 0, $W, $H)
$hPic = GUICtrlGetHandle($Pic)
; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hResize)
$hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hResize Then
_WinAPI_DeleteObject($hResize)
EndIf
GUISetState()
Do
Until GUIGetMsg() = -3