UDF > GDIPlus > Bitmap >


_GDIPlus_BitmapConvertFormat

Convertit un bitmap en un format de pixel sp�cifi�

#include <GDIPlus.au3>
_GDIPlus_BitmapConvertFormat ( $hBitmap, $iPixelFormat, $iDitherType, $iPaletteType, $tPalette [, $fAlphaThresholdPercent = 0.0] )

Param�tres

$hBitmap Handle du bitmap auquel l'effet est appliqu�.
$iPixelFormat Constante de format de pixel qui sp�cifie le nouveau format de pixel ($GDIP_PXF*).
$iDitherType Constante DitherType qui sp�cifie l'algorithme de tramage ($GDIP_DitherType*).
$iPaletteType Constante PaletteType qui sp�cifie une palette standard � utiliser pour le tramage ($GDIP_PaletteType*).
$tPalette Structure qui sp�cifie la palette dont les index sont stock�es dans les donn�es de pixels de l'image bitmap converti.
$fAlphaThresholdPercent [optionnel] Nombre r�el dans la fourchette entre 0,0 et 100,0 qui sp�cifie quels pixels de l'image source sera de couleur transparente dans le bitmap converti.

Valeur de retour

Succ�s: Retourne True.
�chec: Retourne False et d�finit @error <> 0, @extended contient le code erreur ($GPID_ERR*).
@error: -1 - GDIPlus.dll ne supporte pas cette fonction.
10 - Param�tres invalides.

Remarque

La donn�e d'un pixel d'origine dans l'image bitmap est remplac� par la nouvelle donn�e de pixel.

En relation

_GDIPlus_PaletteInitialize

Voir aussi

Consultez GdipBitmapConvertFormat dans la Librairie MSDN.

Exemple

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

_Example()

Func _Example()
    If Not _GDIPlus_Startup() Then
        MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available")
        Return
    EndIf

    Local $sFile = FileOpenDialog("S�lectionnez une image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)")
    If @error Or Not FileExists($sFile) Then Return

    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)

    Local $iWidth = 600
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * 600 / _GDIPlus_ImageGetWidth($hImage)

    Local $hGui = GUICreate("GDI+ v1.1", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    ; Convertit en bitmap 16 couleurs (4 bits par pixel) en utilisant le tramage diffusion
    Local $tPalette = _GDIPlus_PaletteInitialize(16, $GDIP_PaletteTypeOptimal, 16, False, $hImage)
    _GDIPlus_BitmapConvertFormat($hImage, $GDIP_PXF04INDEXED, $GDIP_DitherTypeErrorDiffusion, $GDIP_PaletteTypeOptimal, $tPalette)

    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iWidth, $iHeight)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
EndFunc   ;==>_Example