Funktionreferenz


_GDIPlus_PaletteInitialize


Initializes a standard, optimal, or custom color palette

#include <GDIPlus.au3>
_GDIPlus_PaletteInitialize ( $iEntries [, $iPaletteType = $GDIP_PaletteTypeOptimal [, $iOptimalColors = 0 [, $bUseTransparentColor = True [, $hBitmap = Null]]]] )

Parameter

$iEntries Number of Entries.
$iPaletteType [optional] PaletteType constant that specifies the palette type ($GDIP_PaletteType*).
$iOptimalColors [optional] Integer that specifies the number of colors you want to have in an optimal palette based on a specified bitmap.
If this parameter is greater than 0, the palettetype parameter must be set to PaletteTypeOptimal and the bitmap parameter must point to a Bitmap object.
$bUseTransparentColor [optional] Boolean value that specifies whether to include the transparent color in the palette.
Set to TRUE to include the transparent color; otherwise FALSE.
$hBitmap [optional] Handle of a Bitmap object for which an optimal palette will be created.

Rückgabewert

Success: a DllStruct Palette:
Flags - $iPaletteFlags
Count - $iEntries
ARGB - UINT Array of ARGB colors
Failure: sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3).
@error: -1 - GDIPlus.dll does not support this function.
10 - Invalid parameters.

Bemerkungen

None.

Verwandte Funktionen

_GDIPlus_BitmapConvertFormat

Siehe auch

Suche nach GdipInitializePalette in der MSDN Bibliothek.

Beispiel

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

_Example()

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

    Local $sFile = FileOpenDialog("Select an 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 (" & @ScriptName & ")", $iWidth, $iHeight)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    GUISetState(@SW_SHOW)

    ;Convert to a 16-color bitmap (4 bits per pixel) using FixedHalftone27 dithering
    Local $tPalette = _GDIPlus_PaletteInitialize(16, $GDIP_PaletteTypeFixedHalftone27, 16, False, $hImage)
    _GDIPlus_BitmapConvertFormat($hImage, $GDIP_PXF04INDEXED, $GDIP_DitherTypeDualSpiral8x8, $GDIP_PaletteTypeFixedHalftone27, $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