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 As Integer, _
ByVal As Boolean, _
ByVal As Boolean, _
ByVal As Boolean _
) As GdPictureOutputIntent
public GdPictureOutputIntent ColorDetection(
int ,
bool ,
bool ,
bool
)
public function ColorDetection(
: Integer;
: Boolean;
: Boolean;
: Boolean
): GdPictureOutputIntent;
public function ColorDetection(
: int,
: boolean,
: boolean,
: boolean
) : GdPictureOutputIntent;
public: GdPictureOutputIntent ColorDetection(
int ,
bool ,
bool ,
bool
)
public:
GdPictureOutputIntent ColorDetection(
int ,
bool ,
bool ,
bool
)
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.
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);
}
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