Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Raster imaging C++ Class library help

LBitmapRgn::SetRgnColor

Show in webframe

#include "ltwrappr.h"

virtual L_INT LBitmapRgn::SetRgnColor(crColor)

COLORREF crColor;

/* color to use for the region */

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

Parameter

Description

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

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

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.

See Also

Functions:

LBitmapRgn::SetRgnEllipse, LBitmapRgn::SetRgnPolygon, LBitmapRgn::SetRgnRect, LBitmapRgn::SetRgnRoundRect, LBitmapRgn::SetRgnColorHSVRange, LBitmapRgn::SetRgnColorRGBRange, Class Members

Topics:

Raster Image Functions: Creating and Using a Region

 

Raster Image Functions: Region Processing

 

Defining and Using a Bitmap Region

 

Using Color Values in LEADTOOLS

 

Saving a Region

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
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;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.