UDF > GDIPlus > Bitmap >


_GDIPlus_BitmapCreateFromGraphics

Cr�e un objet Bitmap � partir d'un objet Graphics, avec une largeur et une hauteur donn�es

#include <GDIPlus.au3>
_GDIPlus_BitmapCreateFromGraphics ( $iWidth, $iHeight, $hGraphics )

Param�tres

$iWidth Sp�cifie la largeur, en pixels, du bitmap
$iHeight Sp�cifie la hauteur, en pixels, du Bitmap
$hGraphics Handle de l'objet Graphics

Valeur de retour

Succ�s: Retourne le handle de l'objet Bitmap
�chec: Retourne 0 et d�finit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

Remarque

Lorsque vous en avez termin� avec l'objet bitmap, appelez _GDIPlus_BitmapDispose() pour lib�rer les ressources

En relation

_GDIPlus_BitmapDispose

Voir aussi

Consultez GdipCreateBitmapFromGraphics dans la Librairie MSDN.

Exemple

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

Global $g_hGUI, $g_hBrush, $g_hGfx, $g_hGfxCtxt, $g_hBitmap

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ; Initialise GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ; $iBGColor est au format RRGGBB

    $g_hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Cr�e une interface de test
    GUISetBkColor($iBgColor, $g_hGUI) ; d�finir l'interface graphique couleur de fond
    GUISetState(@SW_SHOW)

    ; Cr�er un buffer graphique pour fluidifier les d�placements d'objets
    $g_hGfx = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ; cr�er un objet graphique � partir d'un handle fen�tre
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGfx) ; Cr�e un objet Bitmap bas� sur un objet graphique
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap) ; Obtient le contexte graphique de l'image/bitmap pour dessiner dans l'image/bitmap
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; D�finit pour l'objet graphique la qualit� de rendu antialiasing

    $g_hBrush = _GDIPlus_BrushCreateSolid(0xFF8080FF) ; Cr�e un objet Brush solide

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Local Const $iDeg = ACos(-1) / 180 ; ACos(-1) est presque pi
    Local $iSize = 50, $iX_Center = ($iWidth - $iSize) / 2, $iY_Center = ($iHeight - $iSize) / 2, $iXPos, $iYPos, $iAngle = 0
    Local Const $iDots = 16, $iAngelDist = 360 / $iDots, $iRadius = 200

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ; Efface le bitmap avec une couleur donn�e (en format AARRGGBB)
        For $i = 1 To $iDots
            $iXPos = $iX_Center + Cos($iAngle * $iDeg) * $iRadius
            $iYPos = $iY_Center + Sin($iAngle * $iDeg) * $iRadius
            _GDIPlus_GraphicsFillEllipse($g_hGfxCtxt, $iXPos, $iYPos, $iSize, $iSize, $g_hBrush) ; Dessine des points dans un cercle
            $iAngle += $iAngelDist ; Augmente l'angle pour le prochain point
        Next
        $iAngle += 1 ; Augmente l'angle global
        _GDIPlus_GraphicsDrawImageRect($g_hGfx, $g_hBitmap, 0, 0, $iWidth, $iHeight) ; Copie le bitmap dessin� dans la GUI
    Until Not Sleep(20) ; Sleep() retourne toujours 1 et non 1 ou 0
EndFunc   ;==>Example

Func _Exit() ; Nettoie les ressources GDI+
    _GDIPlus_BrushDispose($g_hBrush)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGfx)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit