LBitmapRgn::SetRgnColor

Summary

Creates or updates the associated class object's bitmap region by adding a region that consists of all the pixels of a specified color.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmapRgn::SetRgnColor(crColor)

Parameters

COLORREF crColor

The COLORREF value that specifies the color to use for the region. You can specify a COLORREF value, such as the return value of the Windows RGB macro, or you can use the PALETTEINDEX macro to specify a palette color.

Returns

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

Comments

You specify the color using a COLORREF value, which is a Windows-defined data type. You can assign the value using the Windows RGB macro.

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

You can use this function to simulate the use of a transparent color as follows:

  1. Set L_RGN_SETNOT for the CombineMode using LBitmapRgn::SetRgnCombineMode function, then call the LBitmapRgn::SetRgnColor function, with the transparent color in the crColor parameter.

  2. Call the LPaint::PaintRgnDC function to paint the resulting region, which includes everything in the bitmap, except the transparent color.

In the Document and Medical Imaging toolkits, the COLORREF value may represent a 16 bit grayscale value if the bitmap is a 12 or 16-bit grayscale bitmap, or a 32-bit grayscale value if the bitmap 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 LBitmapBase::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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LBitmapRgn__SetRgnColorExample() 
{ 
   L_INT nRet; 
   LBitmapBase MyBitmap(200,300,ORDER_BGR); 
 
 
   nRet = MyBitmap.Load(MAKE_IMAGE_PATH(TEXT("image1.cmp"))); 
   if(nRet !=SUCCESS) 
      return nRet; 
   LBitmapRgn Region(&MyBitmap); 
   //set the red color as a region 
   nRet =Region.SetRgnColor(RGB(255,0,0)); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
Help Version 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.