Convertit un bitmap en un format de pixel spécifié
#include <GDIPlus.au3>
_GDIPlus_BitmapConvertFormat ( $hBitmap, $iPixelFormat, $iDitherType, $iPaletteType, $tPalette [, $fAlphaThresholdPercent = 0.0] )
$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. |
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. |
La donnée d'un pixel d'origine dans l'image bitmap est remplacé par la nouvelle donnée de pixel.
Consultez GdipBitmapConvertFormat dans la Librairie MSDN.
#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