PaletteGetColorsCount Method (GdPictureImaging)
Returns the number of colors contained into the color palette of a GdPicture image.
'Declaration
Public Function PaletteGetColorsCount( _
ByVal As Integer _
) As Integer
public int PaletteGetColorsCount(
int
)
public function PaletteGetColorsCount(
: Integer
): Integer;
public function PaletteGetColorsCount(
: int
) : int;
public: int PaletteGetColorsCount(
int
)
public:
int PaletteGetColorsCount(
int
)
Parameters
- ImageID
- GdPicture image identifier.
Return Value
Number of Imaging.Colors.
Determining the palette entries count of the selected image.
Getting information about the palette entries count of the selected image and showing the result on the screen.
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))
{
int entriesCount = gdpictureImaging.PaletteGetColorsCount(imageID);
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 an image file. An empty string allows the control to prompt for selecting a 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);
}