virtual L_INT LBitmapRgn::SetRgnColor(crColor)
Creates or updates the associated class object's bitmap region by adding a region that consists of all the pixels of a specified color.
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.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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:
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.
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;
Win32, x64.
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 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