Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_SetBitmapRgnColorRGBRange

Show in webframe

#include "l_bitmap.h"

L_LTDIS_API L_INT L_SetBitmapRgnColorRGBRange(pBitmap, crLower, crUpper, uCombineMode)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_COLORREF crLower;

/* minimum RGB color value */

L_COLORREF crUpper;

/* maximum RGB color value */

L_UINT uCombineMode;

/* action to take regarding the existing region */

Creates or updates the bitmap region by adding a region that consists of all the pixels that fall in the range crLower ... crUpper, inclusively.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap where the region is to be created or updated.

crLower

COLORREF that contains the minimum (inclusive) R, G and B values. A pixel must have R,G, and B all greater than or equal to crLower and less than or equal to crUpper to be included in the region.

crUpper

COLORREF that contains the maximum (inclusive) R,G, and B values. A pixel must have R,G, and B all greater than or equal to crLower and less than or equal to crUpper to be included in the region.

uCombineMode

The action to take regarding the existing bitmap region, if one is defined. For descriptions of the possible values, refer to Creating a Bitmap Region.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function uses the RGB color model to set a region based on a color range.

To be added to the region a color must fall in the range crLower..crUpper. To set a region for all pure red, specify crLower and crUpper as follows:

crLower RGB(1,0,0)

crUpper(255,0,0)

Note that this would fail to include many colors that look red to the eye (like RGB(255,4,4)). To include ALL shades of red, you can use L_SetBitmapRgnColorHSVRange.

To update an existing region, specify how the new region is to be combined with the existing one. For descriptions of the possibilities, refer to Creating a Bitmap Region.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.

The standard Windows values for COLORREF represent either red, green, and blue color values, or an index into the bitmap's palette. A COLORREF value with the format 0x00BBGGRR represents the blue, green, and red color values for the specified pixel, where 0xBB is the blue value, 0xGG is the green value and 0xRR is the red value. If 0x01000000 is set in the COLORREF value (0x010000ZZ), the lower 8 bits (0xZZ) represent an index into the bitmap's palette which holds the color value. These COLORREF values can be used with any Windows function and macro that takes a COLORREF parameter.

In the Document and Medical Imaging toolkits, the COLORREF value may represent a 16 bit grayscale value if pBitmap is a 12 or 16-bit grayscale bitmap, or a 32-bit grayscale value if pBitmap is a 32-bit grayscale bitmap. So that the value is not confused with an RGB value, the COLORREF_GRAY16 mask (0x04000000) is set. In this case (0x0400YYYY), the lower 16 bits (0xYYYY) of the COLORREF value represent the 16-bit grayscale value. (0x0400FFFF is 16-bit white and 0x04000000is 16-bit black.) This is not a standard Windows value. Therefore, LEADTOOLS functions will recognize a COLORREF having this format, but Windows functions will not. For information on how to use a 16-bit grayscale COLORREF in a non-LEADTOOLS function, refer to L_GetPixelColor.

If working with 12 and 16-bit grayscale, and (crLower and crUpper) values represent the 16-bit grayscale values, then the function will work on the data. For example, to select the rage between 100 and 130:

 nValue = 100;

 rgbLo = nValue | COLORREF_GRAY16;

 nValue = 130;

 rgbHi = nValue | COLORREF_GRAY16;

Required DLLs and Libraries

LTDIS

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64, Linux.

See Also

Functions:

L_RemapBitmapHue, L_SetBitmapRgnColorHSVRange, L_RGBtoHSV, L_HSVtoRGB, L_SetBitmapRgnEllipse, L_SetBitmapRgnPolygon, L_SetBitmapRgnRect, L_SetBitmapRgnRoundRect

Topics:

Raster Image Functions: Creating and Using a Region

 

Raster Image Functions: Region Processing

 

Creating a Bitmap Region

 

Working with the Existing Bitmap Region

 

Using Color Values in LEADTOOLS

 

Saving a Region

Example

L_INT  SetBitmapRgnColorRGBRangeExample(pBITMAPHANDLE  pBitmap)
{
   COLORREF rgbLo, rgbHi;
   L_INT    nRet;

   rgbLo = RGB(1,0,0);
   rgbHi = RGB(255,0,0);

   nRet = L_SetBitmapRgnColorRGBRange(pBitmap, rgbLo, rgbHi, L_RGN_SET);
   if(nRet != SUCCESS)
      return nRet;

   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.