UDF > GDIPlus > Bitmap >


_GDIPlus_BitmapCreateDIBFromBitmap

Crée une section DIB

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateDIBFromBitmap ( $hBitmap )

Paramètre

$hBitmap Le handle du bitmap GDI+

Valeur de retour

Succès: Retourne le handle de la section du bitmap DIB.
Échec: Retourne 0.

Remarque

Après utilisation de l'objet, appelez _WinAPI_DeleteObject() pour libérer les ressources de l'objet.

En relation

_WinAPI_DeleteObject

Voir aussi

Consultez CreateDIBSection dans la librairie MSDN.

Exemple

; Support PNG by UEZ

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIHObj.au3>

; Crée une GUI
Local $hMainGUI = GUICreate("Show PNG", 210, 210)

_GUICtrlPic_Create("..\GUI\Torus.png", 10, 10);, 100, 100)

GUISetState(@SW_SHOW)

; Boucle jusqu'à ce que l'utilisateur quitte.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

; #INTERNAL_USE_ONLY#=================================================================================================
; Name...........: _GUICtrlPic_Create
; Description ...: Crée un contrôle Picture dans une GUI
; Syntax ........: _GUICtrlPic_Create($sFilename, $iLeft, $iTop, $iWidth, $iHeight, $iStyle = -1 , $iExStyle = -1)
; Parameters ....: $sFilename - Nom complet du fichier image
; Author ........: UEZ
; Modified.......: Melba23, guinness, jpm
; Remarks .......: Une image PNG est supportée.
; ====================================================================================================================
Func _GUICtrlPic_Create($sFilename, $iLeft, $iTop, $iWidth = -1, $iHeight = -1, $iStyle = -1, $iExStyle = -1)
    _GDIPlus_Startup()
    Local $idPic = GUICtrlCreatePic("", $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle)
    Local $hBitmap = _GDIPlus_BitmapCreateFromFile($sFilename)
    If $iWidth = -1 Then $iWidth = _GDIPlus_ImageGetWidth($hBitmap)
    If $iHeight = -1 Then $iHeight = _GDIPlus_ImageGetHeight($hBitmap)
    Local $hBitmap_Resized = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
    Local $hBMP_Ctxt = _GDIPlus_ImageGetGraphicsContext($hBitmap_Resized)
    _GDIPlus_GraphicsSetInterpolationMode($hBMP_Ctxt, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)
    _GDIPlus_GraphicsDrawImageRect($hBMP_Ctxt, $hBitmap, 0, 0, $iWidth, $iHeight)
    Local $hHBitmap = _GDIPlus_BitmapCreateDIBFromBitmap($hBitmap_Resized)
    Local $hPrevImage = GUICtrlSendMsg($idPic, $STM_SETIMAGE, 0, $hHBitmap) ; $STM_SETIMAGE = 0x0172
    _WinAPI_DeleteObject($hPrevImage); Delete Prev image if any
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap_Resized)
    _GDIPlus_GraphicsDispose($hBMP_Ctxt)
    _WinAPI_DeleteObject($hHBitmap)
    _GDIPlus_Shutdown()

    Return $idPic
EndFunc   ;==>_GUICtrlPic_Create