GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / ColorDetection Method
GdPicture image identifier.
Set True to automatically convert the image in its best suited / optimized bits-per-pixel encoding, otherwise False.
This parameter is not used anymore. You can specify any value.
Set True to enable characters repairing during bitonal conversion, if any. This feature is suggested for scanned gray papers acquired in color.
Example





In This Topic
ColorDetection Method (GdPictureImaging)
In This Topic
Performs color detection on an image. Detecting the color scheme can help to dramatically reduce the size of electronically stored documents.
Syntax
'Declaration
 
Public Function ColorDetection( _
   ByVal ImageID As Integer, _
   ByVal AutoConvert As Boolean, _
   ByVal ScanningContext As Boolean, _
   ByVal AutoRepairCharacters As Boolean _
) As GdPictureOutputIntent
public GdPictureOutputIntent ColorDetection( 
   int ImageID,
   bool AutoConvert,
   bool ScanningContext,
   bool AutoRepairCharacters
)
public function ColorDetection( 
    ImageID: Integer;
    AutoConvert: Boolean;
    ScanningContext: Boolean;
    AutoRepairCharacters: Boolean
): GdPictureOutputIntent; 
public function ColorDetection( 
   ImageID : int,
   AutoConvert : boolean,
   ScanningContext : boolean,
   AutoRepairCharacters : boolean
) : GdPictureOutputIntent;
public: GdPictureOutputIntent ColorDetection( 
   int ImageID,
   bool AutoConvert,
   bool ScanningContext,
   bool AutoRepairCharacters
) 
public:
GdPictureOutputIntent ColorDetection( 
   int ImageID,
   bool AutoConvert,
   bool ScanningContext,
   bool AutoRepairCharacters
) 

Parameters

ImageID
GdPicture image identifier.
AutoConvert
Set True to automatically convert the image in its best suited / optimized bits-per-pixel encoding, otherwise False.
ScanningContext
This parameter is not used anymore. You can specify any value.
AutoRepairCharacters
Set True to enable characters repairing during bitonal conversion, if any. This feature is suggested for scanned gray papers acquired in color.

Return Value

A member of the GdPictureOutputIntent enumeration.
Remarks

This method requires the MRC - Hyper Compression component to run.

Example
Saving an image to tiff ccitt iv or jpeg depending on the colors used.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp", true);
 
    // Compute the color intent and save to tiff ccitt iv when suitable.
    // Save to jpeg when the image is not just black and white.
 
    GdPictureOutputIntent intent = gdpictureImaging.ColorDetection(imageID, true /* AutoConvert*/, true, true /* AutoRepairCharacters */);
 
    switch (intent)
    {
        case GdPictureOutputIntent.IntentBlackWhite:
        case GdPictureOutputIntent.IntentWhite:
            gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
            break;
 
        case GdPictureOutputIntent.IntentGrayscale:
        case GdPictureOutputIntent.IntentColor:
        case GdPictureOutputIntent.IntentPalletized:
            gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
            break;
    }
 
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also