L_SetBitmapRgnColor

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_SetBitmapRgnColor(pBitmap, crColor, uCombineMode)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

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

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.

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.

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

Windows 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_SetBitmapRgnEllipse, L_SetBitmapRgnPolygon, L_SetBitmapRgnRect, L_SetBitmapRgnRoundRect

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

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. */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the image */
void TestFunction ( HWND hWnd )
{
   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 */
   L_LoadBitmap (TEXT("image3.cmp"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   /* Posterize the bitmap to decrease the number of colors */
   L_PosterizeBitmap(&LeadBitmap,16);
   /* Specify a pixel in the upper left of the displayed image */
   XOffset = BITMAPWIDTH(&LeadBitmap) / 8;
   YOffset = BITMAPHEIGHT(&LeadBitmap) / 8;
   /* Adjust the YOffset in case the view perspective is not TOP_LEFT */
   L_PointToBitmap ( &LeadBitmap, TOP_LEFT, &XOffset, &YOffset );
   /* Get the color of the specified pixel */
   RgnColor = L_GetPixelColor(&LeadBitmap, YOffset, XOffset);
   /* Create a region that includes all pixels of that color */
   L_SetBitmapRgnColor(&LeadBitmap, RgnColor, L_RGN_SET);
   /* Fill the region with blue */
   L_FillBitmap(&LeadBitmap,RGB(0, 0, 255) );
   /* Free the region */
   L_FreeBitmapRgn(&LeadBitmap);
   return;
}