GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureImaging Class / PaletteSwapEntries Method
GdPicture image identifier.
Index of the color palette to swap with the second. Must be a value between 0 and PaletteGetColorsCount() - 1 returned value.
Index of the color palette to swap with the first. Must be a value between 0 and PaletteGetColorsCount() - 1 returned value.
Example





In This Topic
PaletteSwapEntries Method (GdPictureImaging)
In This Topic
Returns the color of a specific entry of the palette of a GdPicture image.
Syntax
'Declaration
 
Public Function PaletteSwapEntries( _
   ByVal ImageID As Integer, _
   ByVal Entrie1 As Integer, _
   ByVal Entrie2 As Integer _
) As GdPictureStatus
public GdPictureStatus PaletteSwapEntries( 
   int ImageID,
   int Entrie1,
   int Entrie2
)
public function PaletteSwapEntries( 
    ImageID: Integer;
    Entrie1: Integer;
    Entrie2: Integer
): GdPictureStatus; 
public function PaletteSwapEntries( 
   ImageID : int,
   Entrie1 : int,
   Entrie2 : int
) : GdPictureStatus;
public: GdPictureStatus PaletteSwapEntries( 
   int ImageID,
   int Entrie1,
   int Entrie2
) 
public:
GdPictureStatus PaletteSwapEntries( 
   int ImageID,
   int Entrie1,
   int Entrie2
) 

Parameters

ImageID
GdPicture image identifier.
Entrie1
Index of the color palette to swap with the second. Must be a value between 0 and PaletteGetColorsCount() - 1 returned value.
Entrie2
Index of the color palette to swap with the first. Must be a value between 0 and PaletteGetColorsCount() - 1 returned value.

Return Value

A member of the GdPictureStatus enumeration.
Example
Opening a B&W indexed image, swapping palette entries and saving the result into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // Open an image file. An empty string allows the control to prompt for selecting a file.
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
 
    if (gdpictureImaging.PaletteGetColorsCount(imageID) == 2)
    {
        // Swapping palette entries in B&W image means that the image will be inverted.
        gdpictureImaging.PaletteSwapEntries(imageID, 0, 1);
        gdpictureImaging.SaveAsPNG(imageID, "output.png");
    }
    else Console.WriteLine("The loaded image is not of B&W type!");
 
    // Release used resources.
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also