Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_SetBitmapRgnColor
#include "l_bitmap.h"
L_LTDIS_API L_INT L_SetBitmapRgnColor(pBitmap, crColor, uCombineMode)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
L_COLORREF crColor; |
/* color to use for the region */ |
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 of a specified color.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the bitmap where the region is to be created or updated. |
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. |
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 does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
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. |
Call the L_SetBitmapRgnColor function, with the transparent color in the crColor parameter and L_RGN_SETNOT in the uCombineMode parameter. |
2. |
Call the L_PaintRgnDC function to paint the resulting region, which includes everything in the bitmap, except the transparent color. |
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: |
L_SetBitmapRgnEllipse, L_SetBitmapRgnPolygon, L_SetBitmapRgnRect, L_SetBitmapRgnRoundRect |
Topics: |
|
|
|
|
|
|
|
|
Example
For complete sample code, refer to the FEATURE3 example. This example creates a region that includes all pixels of a specified color. It then fills the region with blue.
L_INT SetBitmapRgnColorExample(pBITMAPHANDLE pBitmap) { L_INT nRet; COLORREF RgnColor; /* Color to use when defining the region */ L_INT XOffset, YOffset; /* Pixel coordinates for getting a color from the bitmap */ /* Load the bitmap, at its own bits per pixel */ if(pBitmap->Flags.Allocated) L_FreeBitmap(pBitmap); nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), pBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet != SUCCESS) return nRet; /* Posterize the bitmap to decrease the number of colors */ #if defined LEADTOOLS_V16_OR_LATER nRet = L_PosterizeBitmap(pBitmap,16, 0); #else nRet = L_PosterizeBitmap(pBitmap,16); #endif if(nRet != SUCCESS) return nRet; /* Specify a pixel in the upper left of the displayed image */ XOffset = BITMAPWIDTH(pBitmap) / 8; YOffset = BITMAPHEIGHT(pBitmap) / 8; /* Adjust the YOffset in case the view perspective is not TOP_LEFT */ nRet = L_PointToBitmap ( pBitmap, TOP_LEFT, &XOffset, &YOffset ); if(nRet != SUCCESS) return nRet; /* Get the color of the specified pixel */ RgnColor = L_GetPixelColor(pBitmap, YOffset, XOffset); /* Create a region that includes all pixels of that color */ nRet = L_SetBitmapRgnColor(pBitmap, RgnColor, L_RGN_SET); if(nRet != SUCCESS) return nRet; /* Fill the region with blue */ L_FillBitmap(pBitmap,RGB(0, 0, 255) ); /* Free the region */ L_FreeBitmapRgn(pBitmap); return SUCCESS; }