L_GetBitmapColorType

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_GetBitmapColorType(pBitmap, puType, puConfidence, uFlag)

Gets the color type of the bitmap (black and white, color or grayscale), along with the confidence level.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap whose color type will be retrieved.

L_UINT * puType

Pointer to a variable to be updated with the color type of the bitmap. Possible values are:

Value Meaning
BITMAP_COLORTYPE_BLACKANDWHITE [0x00000001] The bitmap is black and white.
BITMAP_COLORTYPE_GRAYSCALE [0x00000002] The bitmap is grayscale.
BITMAP_COLORTYPE_COLOR [0x00000003] The bitmap is color.

L_INT * puConfidence

Pointer to a variable to be updated with the level of accuracy. Possible values are range from 50 to 100.

L_UINT uFlag

A flag that is used to make the algorithm favor one type of bitmap over the others. For example, if color bitmaps are expected to be detected, even if they are more grayscale, they can be favored by passing BITMAP_COLORTYPE_FAVOR_COLOR. Possible values are:

Value Meaning
BITMAP_COLORTYPE_FAVOR_COLOR [0x00000001] Favor color bitmaps over other types.
BITMAP_COLORTYPE_FAVOR_BLACKANDWHITE [0x00000002] Favor black and white bitmaps over other types..
BITMAP_COLORTYPE_FAVOR_GRAYSCALE [0x00000004] Favor grayscale bitmaps over other types.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This functions works with 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48 and 64-bit images.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example gets the type of the image and whether it's black and white, colored or grayscale, along with the confidence level.

L_INT  GetBitmapColorTypeExample(pBITMAPHANDLE pBitmap) 
{ 
   L_INT nRet = 0; 
   L_UINT uType = 0; /* bitmap color type */ 
   L_INT uConfidence = 0; /* confidence */ 
 
   L_TCHAR szMessage[80]; /* Buffer for the MessageBox string */ 
   nRet = L_GetBitmapColorType(pBitmap, &uType, &uConfidence, BITMAP_COLORTYPE_FAVOR_COLOR); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Display the result in a message */ 
   switch(uType) 
   { 
      case BITMAP_COLORTYPE_BLACKANDWHITE: 
         wsprintf( szMessage, TEXT("The bitmap is Black and White: %ld"), uConfidence ); 
         break; 
      case BITMAP_COLORTYPE_GRAYSCALE: 
         wsprintf( szMessage, TEXT("The bitmap is Grayscale: %ld"), uConfidence ); 
         break; 
      case BITMAP_COLORTYPE_COLOR: 
         wsprintf( szMessage, TEXT("The bitmap is Color: %ld"), uConfidence ); 
         break; 
   } 
   MessageBox (NULL, szMessage, TEXT("Result"), MB_OK); 
 
   return SUCCESS; 
} 

Help Version 20.0.2019.9.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help