<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><HTML> <HEAD><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <TITLE>color - Methods to Count the Colors in an Image</TITLE> <link rel="StyleSheet" href="../magick.css" type="text/css"> </HEAD> <body bgcolor="#FFFFFF" text="#000000" link="#0085c0" alink="#0085c0" vlink="#800080"> <A NAME="__index__"></A> <!-- INDEX BEGIN --> <UL> <LI><A HREF="#name"> <FONT SIZE=-1>NAME</FONT></A> <LI><A HREF="#synopsis"> <FONT SIZE=-1>SYNOPSIS</FONT></A> <LI><A HREF="#function descriptions"> <FONT SIZE=-1>FUNCTION</FONT> <FONT SIZE=-1>DESCRIPTIONS</FONT></A> <UL> <LI><A HREF="#getcolorlist">GetColorlist</A> <LI><A HREF="#getnumbercolors">GetNumberColors</A> <LI><A HREF="#isgrayimage">IsGrayImage</A> <LI><A HREF="#ismonochromeimage">IsMonochromeImage</A> <LI><A HREF="#isopaqueimage">IsOpaqueImage</A> <LI><A HREF="#ispaletteimage">IsPaletteImage</A> <LI><A HREF="#listcolorinfo">ListColorInfo</A> <LI><A HREF="#querycolordatabase">QueryColorDatabase</A> <LI><A HREF="#querycolorname">QueryColorname</A> </UL> </UL> <!-- INDEX END --> <HR> <P> <H1><A NAME="name"> <FONT SIZE=-1>NAME</FONT></A></H1> <P>color - Methods to Count the Colors in an Image</P> <P> <HR> <H1><A NAME="synopsis"> <FONT SIZE=-1>SYNOPSIS</FONT></A></H1> <P>unsigned long <STRONG>GetNumberColors</STRONG>( const Image *image, <FONT SIZE=-1>FILE</FONT> *file, ExceptionInfo *exception );</P> <P>unsigned int <STRONG>IsGrayImage</STRONG>( const Image *image, ExceptionInfo *exception );</P> <P>unsigned int <STRONG>IsMonochromeImage</STRONG>( const Image *image, ExceptionInfo *exception );</P> <P>unsigned int <STRONG>IsOpaqueImage</STRONG>( const Image *image, ExceptionInfo *exception );</P> <P>unsigned int <STRONG>IsPaletteImage</STRONG>( const Image *image, ExceptionInfo *exception );</P> <P>unsigned int <STRONG>ListColorInfo</STRONG>( <FONT SIZE=-1>FILE</FONT> *file, ExceptionInfo *exception );</P> <P>unsigned int <STRONG>QueryColorDatabase</STRONG>( const char *name, PixelPacket *color, ExceptionInfo *exception );</P> <P>unsigned int <STRONG>QueryColorname</STRONG>( const Image *image, const PixelPacket *color, const ComplianceType compliance, char *name, ExceptionInfo *exception );</P> <P> <HR> <H1><A NAME="function descriptions"> <FONT SIZE=-1>FUNCTION</FONT> <FONT SIZE=-1>DESCRIPTIONS</FONT></A></H1> <P> <H2><A NAME="getcolorlist">GetColorlist</A></H2> <P>Method GetColorList returns any colors that match the specified pattern and color standard.</P> <P>The format of the GetColorList function is:</P> <PRE> filelist=GetColorList(const char *pattern,int number_colors)</PRE> <P> <FONT SIZE=-1>A</FONT> description of each parameter follows:</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG><A NAME="item_o_filelist%3A">filelist:</A></STRONG><BR> <DD> Method GetColorList returns a list of colors that match the specified pattern and color standard. <P></P> <dd><p></p><dt><STRONG><A NAME="item_o_pattern%3A">pattern:</A></STRONG><BR> <DD> Specifies a pointer to a text string containing a pattern. <P></P> <dd><p></p><dt><STRONG><A NAME="item_o_number_colors%3A">number_colors:</A></STRONG><BR> <DD> This integer returns the number of colors in the list. <P></P></DL></DL> <P> <H2><A NAME="getnumbercolors">GetNumberColors</A></H2> <P>Method GetNumberColors returns the number of unique colors in an image.</P> <P>The format of the GetNumberColors method is:</P> <blockquote>unsigned long GetNumberColors ( const <A HREF="types/Image.html">Image</A> *image, FILE *file, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows.</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG><A NAME="item_o_image%3A">image:</A></STRONG><BR> <DD> The image. <P></P> <dd><p></p><dt><STRONG><A NAME="item_o_file%3A">file:</A></STRONG><BR> <DD> Write a histogram of the color distribution to this file handle. <P></P> <dd><p></p><dt><STRONG><A NAME="item_o_exception%3A">exception:</A></STRONG><BR> <DD> Return any errors or warnings in this structure. <P></P></DL></DL> <P> <H2><A NAME="isgrayimage">IsGrayImage</A></H2> <blockquote>IsGrayImage() returns True if all the pixels in the image have the same red, green, and blue intensities. </blockquote><P>The format of the IsGrayImage method is:</P> <blockquote>unsigned int IsGrayImage ( const <A HREF="types/Image.html">Image</A> *image, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows:</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG><A NAME="item_o_status%3A">status:</A></STRONG><BR> <DD> Method IsGrayImage returns True if the image is grayscale otherwise False is returned. <P></P> <dd><p></p><dt><STRONG>image:</STRONG><BR> <DD> The image. <P></P> <dd><p></p><dt><STRONG>exception:</STRONG><BR> <DD> Return any errors or warnings in this structure. <P></P></DL></DL> <P> <H2><A NAME="ismonochromeimage">IsMonochromeImage</A></H2> <blockquote>IsMonochromeImage() returns True if all the pixels in the image have the same red, green, and blue intensities and the intensity is either 0 or MaxRGB. </blockquote><P>The format of the IsMonochromeImage method is:</P> <blockquote>unsigned int IsMonochromeImage ( const <A HREF="types/Image.html">Image</A> *image, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows:</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG>image:</STRONG><BR> <DD> The image. <P></P> <dd><p></p><dt><STRONG>exception:</STRONG><BR> <DD> Return any errors or warnings in this structure. <P></P></DL></DL> <P> <H2><A NAME="isopaqueimage">IsOpaqueImage</A></H2> <blockquote>IsOpaqueImage() returns True if none of the pixels in the image have an opacity value other than opaque ( 0 ) . </blockquote><P>The format of the IsOpaqueImage method is:</P> <blockquote>unsigned int IsOpaqueImage ( const <A HREF="types/Image.html">Image</A> *image, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows:</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG>status:</STRONG><BR> <DD> Method IsOpaqueImage returns False if the image has one or more pixels that are transparent otherwise True is returned. <P></P> <dd><p></p><dt><STRONG>image:</STRONG><BR> <DD> The image. <P></P> <dd><p></p><dt><STRONG>exception:</STRONG><BR> <DD> Return any errors or warnings in this structure. <P></P></DL></DL> <P> <H2><A NAME="ispaletteimage">IsPaletteImage</A></H2> <P>Method IsPaletteImage returns True if the image is PseudoClass and has 256 unique colors or less.</P> <P>The format of the IsPaletteImage method is:</P> <blockquote>unsigned int IsPaletteImage ( const <A HREF="types/Image.html">Image</A> *image, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows.</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG>status:</STRONG><BR> <DD> Method IsPaletteImage returns True is the image is PseudoClass or has 256 color or less. <P></P> <dd><p></p><dt><STRONG>image:</STRONG><BR> <DD> The image. <P></P> <dd><p></p><dt><STRONG>exception:</STRONG><BR> <DD> Return any errors or warnings in this structure. <P></P></DL></DL> <P> <H2><A NAME="listcolorinfo">ListColorInfo</A></H2> <blockquote>ListColorInfo() lists color names to the specified file. Color names are a convenience. Rather than defining a color by its red, green, and blue intensities just use a color name such as white, blue, or yellow. </blockquote><P>The format of the ListColorInfo method is:</P> <blockquote>unsigned int ListColorInfo ( FILE *file, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows.</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG>file:</STRONG><BR> <DD> List color names to this file handle. <P></P> <dd><p></p><dt><STRONG>exception:</STRONG><BR> <DD> Return any errors or warnings in this structure. <P></P></DL></DL> <P> <H2><A NAME="querycolordatabase">QueryColorDatabase</A></H2> <blockquote>QueryColorDatabase() returns the red, green, blue, and opacity intensities for a given color name. </blockquote><P>The format of the QueryColorDatabase method is:</P> <blockquote>unsigned int QueryColorDatabase ( const char *name, <A HREF="types/PixelPacket.html">PixelPacket</A> *color, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows:</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG><A NAME="item_o_name%3A">name:</A></STRONG><BR> <DD> The color name (e.g. white, blue, yellow). <P></P> <dd><p></p><dt><STRONG><A NAME="item_o_color%3A">color:</A></STRONG><BR> <DD> The red, green, blue, and opacity intensities values of the named color in this structure. <P></P> <dd><p></p><dt><STRONG>exception:</STRONG><BR> <DD> Return any errors or warnings in this structure. <P></P></DL></DL> <P> <H2><A NAME="querycolorname">QueryColorname</A></H2> <blockquote>QueryColorname() returns a named color for the given color intensity. If an exact match is not found, a hex value is return instead. For example an intensity of rgb: ( 0, 0, 0 ) returns black whereas rgb: ( 223, 223, 223 ) returns #dfdfdf. </blockquote><P>The format of the QueryColorname method is:</P> <blockquote>unsigned int QueryColorname ( const <A HREF="types/Image.html">Image</A> *image, const <A HREF="types/PixelPacket.html">PixelPacket</A> *color, const ComplianceType compliance, char *name, <A HREF="types/ExceptionInfo.html">ExceptionInfo</A> *exception ); </blockquote><P> <FONT SIZE=-1>A</FONT> description of each parameter follows.</P> <DL><DT><DD><DL> <dd><p></p><dt><STRONG>image:</STRONG><BR> <DD> The image. <P></P> <dd><p></p><dt><STRONG>color:</STRONG><BR> <DD> The color intensities. <P></P> <dd><p></p><dt><STRONG><A NAME="item_o_Compliance%3A">Compliance:</A></STRONG><BR> <DD> Adhere to this color standard: <FONT SIZE=-1>SVG,</FONT> <FONT SIZE=-1>X11,</FONT> or <FONT SIZE=-1>XPM.</FONT> <P></P> <dd><p></p><dt><STRONG>name:</STRONG><BR> <DD> Return the color name or hex value. <P></P> <dd><p></p><dt><STRONG>exception:</STRONG><BR> <DD> Return any errors or warnings in this structure. </DL></DL> </BODY> </HTML>