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





In This Topic
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 ImageID As Integer _
) As Integer
public int CountUniqueColors( 
   int ImageID
)
public function CountUniqueColors( 
    ImageID: Integer
): Integer; 
public function CountUniqueColors( 
   ImageID : int
) : int;
public: int CountUniqueColors( 
   int ImageID
) 
public:
int CountUniqueColors( 
   int ImageID
) 

Parameters

ImageID
GdPicture image identifier.

Return Value

The number of unique colors.
Remarks
Use the GetStat() method to check if this method has completed successfully.

This method requires the Image Documents component to run.

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