Gets the color type of the bitmap (black and white, color or grayscale), along with the confidence level.
#include "l_bitmap.h"
L_LTIMGCOR_API L_INT L_GetBitmapColorType(pBitmap, puType, puConfidence, uFlag)
Pointer to the bitmap handle referencing the bitmap whose color type will be retrieved.
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. |
Pointer to a variable to be updated with the level of accuracy. Possible values are range from 50 to 100.
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. |
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This functions works with 1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48 and 64-bit images.
Win32, x64, Linux.
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(L_VOID)
{
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 */
BITMAPHANDLE LeadBitmap;
/* Load the bitmap, keeping the bits per pixel of the file */
nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("Master.jpg")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
if (nRet != SUCCESS)
return nRet;
nRet = L_GetBitmapColorType(&LeadBitmap, &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;
}
_tprintf(_T("Result: %s\n"), szMessage);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document