_GDIPlus_Startup()
$hPng = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\button.png')
$hBitmap = _GDIPlus_DIBitmapCreateFromBitmap($hPng)
_GDIPlus_ImageDispose($hPng)
_GDIPlus_ShutDown()
;GUICtrlSendMsg(-1, $BM_SETIMAGE, $IMAGE_BITMAP, $hBitmap)
GUICtrlSendMsg(-1, 0x00F7, 0, $hBitmap)
GUISetState()
Do
Until GUIGetMsg() = -3
Func _GDIPlus_DIBitmapCreateFromBitmap($hBitmap)
Local $tBIHDR, $tMap, $pBits, $hImage, $hResult, $Width, $Height
$Width = _GDIPlus_ImageGetWidth($hBitmap)
$Height = _GDIPlus_ImageGetHeight($hBitmap)
If ($Width < 1) Or ($Height < 1) Then
Return 0
EndIf
$hImage = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, $Width, $Height, $GDIP_PXF32ARGB)
$tMap = _GDIPlus_BitmapLockBits($hImage, 0, 0, $Width, $Height, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
$tBIHDR = DllStructCreate($tagBITMAPINFOHEADER)
DllStructSetData($tBIHDR, 'biSize', DllStructGetSize($tBIHDR))
DllStructSetData($tBIHDR, 'biWidth', $Width)
DllStructSetData($tBIHDR, 'biHeight', $Height)
DllStructSetData($tBIHDR, 'biPlanes', 1)
DllStructSetData($tBIHDR, 'biBitCount', 32)
DllStructSetData($tBIHDR, 'biCompression', $BI_RGB)
$hResult = _WinAPI_CreateDIBSection(0, $tBIHDR, $DIB_RGB_COLORS, $pBits)
If Not @error Then
_WinAPI_SetBitmapBits($hResult, $Width * $Height * 4, DllStructGetData($tMap, 'Scan0'))
EndIf
_GDIPlus_BitmapUnlockBits($hImage, $tMap)
_GDIPlus_BitmapDispose($hImage)
Return $hResult
EndFunc ;==>_GDIPlus_DIBitmapCreateFromBitmap