GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / PaletteGet Method
GdPicture image identifier.
Output parameter. Array of Color Objects. Color array which will contain the complete color palette.
Output parameter. Contains the number of colors contained in the ColorEntries() array.
Example





In This Topic
PaletteGet Method (GdPictureImaging)
In This Topic
Gets into a 1D array the complete color palette of a GdPicture image.
Syntax
'Declaration
 
Public Function PaletteGet( _
   ByVal ImageID As Integer, _
   ByRef ColorEntries() As Color, _
   ByRef EntriesCount As Integer _
) As GdPictureStatus
public GdPictureStatus PaletteGet( 
   int ImageID,
   ref Color[] ColorEntries,
   ref int EntriesCount
)
public function PaletteGet( 
    ImageID: Integer;
   var  ColorEntries: Colorarray of;
   var  EntriesCount: Integer
): GdPictureStatus; 
public function PaletteGet( 
   ImageID : int,
   ColorEntries : Color[],
   EntriesCount : int
) : GdPictureStatus;
public: GdPictureStatus PaletteGet( 
   int ImageID,
   ref Color[]* ColorEntries,
   ref int EntriesCount
) 
public:
GdPictureStatus PaletteGet( 
   int ImageID,
   array<Color>^% ColorEntries,
   int% EntriesCount
) 

Parameters

ImageID
GdPicture image identifier.
ColorEntries
Output parameter. Array of Color Objects. Color array which will contain the complete color palette.
EntriesCount
Output parameter. Contains the number of colors contained in the ColorEntries() array.

Return Value

A member of the GdPictureStatus enumeration.
Example
Storing the color palette into the array and showing information about entries count.
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.IsPixelFormatIndexed(imageID))
    {
        System.Drawing.Color[] palette = null;
        int entriesCount = 0;
        gdpictureImaging.PaletteGet(imageID, ref palette, ref entriesCount);
 
        Console.WriteLine("Image contains palete with {0} color entries.", entriesCount.ToString());
    }
    else Console.WriteLine("Image do not contain indexed colors!");
 
    // Release used resources.
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also