函数参考


_WinAPI_AdjustBitmap

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 值.

注意/说明

The _WinAPI_AdjustBitmap() creates a device-depended bitmaps compatible with the application's current screen.

This function does not support bitmaps with alpha channel, you can use the _WinAPI_AlphaBlend() function to work
with these bitmaps.

When you are finished using the bitmap, destroy it using the _WinAPI_DeleteObject() function. The function
does not destroy the original bitmap, you must to destroy it yourself.

相关

详情参考

None

示例/演示


#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