Creates a new device-depended bitmap (DDB) from the source bitmap with new dimensions and color adjustment
#include <WinAPIGdi.au3>
_WinAPI_AdjustBitmap ( $hBitmap, $iWidth, $iHeight [, $iMode = 3 [, $tAdjustment = 0]] )
$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 | [optional] The stretching mode. This parameter can be one of the following values: $BLACKONWHITE $COLORONCOLOR (Default) $HALFTONE $WHITEONBLACK $STRETCH_ANDSCANS $STRETCH_DELETESCANS $STRETCH_HALFTONE $STRETCH_ORSCANS |
$tAdjustment | [optional] $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). |
Failure: | 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.
_WinAPI_AlphaBlend, _WinAPI_DeleteObject
#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIHObj.au3>
#include <WinAPIRes.au3>
; Load and resize (x2) image
Local $hBitmap = _WinAPI_LoadImage(0, @ScriptDir & '\Extras\AutoIt.bmp', $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
Local $tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
Local $W = 2 * DllStructGetData($tSIZE, 'X')
Local $H = 2 * DllStructGetData($tSIZE, 'Y')
Local $hResize = _WinAPI_AdjustBitmap($hBitmap, $W, $H)
_WinAPI_DeleteObject($hBitmap)
; Create GUI
Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), $W, $H)
Local $idPic = GUICtrlCreatePic('', 0, 0, $W, $H)
Local $hPic = GUICtrlGetHandle($idPic)
; Set bitmap to control
_SendMessage($hPic, $STM_SETIMAGE, 0, $hResize)
Local $hObj = _SendMessage($hPic, $STM_GETIMAGE)
If $hObj <> $hResize Then
_WinAPI_DeleteObject($hResize)
EndIf
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE