GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureImaging Class / IsPixelFormatIndexed Method
GdPicture image identifier.
Example





In This Topic
IsPixelFormatIndexed Method (GdPictureImaging)
In This Topic
Asks if the pixel format of a GdPicture image is indexed.
Syntax
'Declaration
 
Public Function IsPixelFormatIndexed( _
   ByVal ImageID As Integer _
) As Boolean
public bool IsPixelFormatIndexed( 
   int ImageID
)
public function IsPixelFormatIndexed( 
    ImageID: Integer
): Boolean; 
public function IsPixelFormatIndexed( 
   ImageID : int
) : boolean;
public: bool IsPixelFormatIndexed( 
   int ImageID
) 
public:
bool IsPixelFormatIndexed( 
   int ImageID
) 

Parameters

ImageID
GdPicture image identifier.

Return Value

True if the pixel format is indexed else False.
Example
Processing images with the indexed pixel format.
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);
}
Getting information about the specific palette entry of the selected image and showing the result on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // Open image file. Empty string allows the control to prompt for a selecting file.
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
 
    if (gdpictureImaging.IsPixelFormatIndexed(imageID))
    {
        int entriesCount = gdpictureImaging.PaletteGetColorsCount(imageID);
 
        if (entriesCount>255)
        {
            System.Drawing.Color entryColor = gdpictureImaging.PaletteGetEntry(imageID,130);
            Console.WriteLine("Color value of palette entry [130] is: {0}", entryColor.ToString());
        }
        else Console.WriteLine("Image do not contain palette with 256 colors!");
    }
    else Console.WriteLine("Image do not contain indexed colors!");
 
    // Release used resources
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also