CountUniqueColors Method (GdPictureImaging)
In This Topic
Counts the number of unique colors in a GdPicture image or into an area of a GdPicture image defined by SetROI() method.
Syntax
'Declaration
Public Function CountUniqueColors( _
ByVal As Integer _
) As Integer
public int CountUniqueColors(
int
)
public function CountUniqueColors(
: Integer
): Integer;
public function CountUniqueColors(
: int
) : int;
public: int CountUniqueColors(
int
)
public:
int CountUniqueColors(
int
)
Parameters
- ImageID
- GdPicture image identifier.
Return Value
The number of unique colors.
Example
Showing the number of unique colors on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Count and display the number of colors.
int colorCount = gdpictureImaging.CountUniqueColors(imageID);
MessageBox.Show("Number of unique colors is " + colorCount, "Colors count", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Example
Showing the number of unique colors on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Count and display the number of colors.
int colorCount = gdpictureImaging.CountUniqueColors(imageID);
MessageBox.Show("Number of unique colors is " + colorCount, "Colors count", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also