LBitmapRgn::SetRgnMagicWand

#include "ltwrappr.h"

virtual L_INT LBitmapRgn::SetRgnMagicWand(x, y, uTolerance, crLowerTolerance, crUpperTolerance)

L_INT x;

/* x coordinate */

L_INT y;

/* y coordinate */

COLORREF crLowerTolerance;

/* lower tolerance values */

COLORREF crUpperTolerance;

/* upper tolerance values */

 

Sets a region in the associated class object's bitmap based on the color found at point x, y in the region.

Parameter

Description

x

X coordinate of a point. The color of the specified point will be used to set the region.

y

Y coordinate of a point. The color of the specified point will be used to set the region.

crLowerTolerance

Lower tolerance values that set the lower stopping point for the region.

crUpperTolerance

Upper tolerance values that set the upper stopping point for the region.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

For color bitmaps:

If the value at pixel (x, y) is (125, 125, 125) and crLowerTolerance is (20, 30, 15) the lower stopping point is (105, 95, 110). If crUpperTolerance is (10, 25, 20), then the upper stopping point is (135, 150, 145). Pixels with values of (105, 95, 110) up to (135, 150, 145) will be included in the region.

For gray scale bitmaps:

The minimum channel tolerance value of crLowerTolerance will be used to set the lower stopping point, and the value of crUpperTolerance will be used to set the upper stopping point. For example, if the value of the pixel at (x, y) is (125, 125, 125) and crLowerTolerance is (20,30,15), the smallest value of the triplet (15) will be used to create the lower stopping point of (110,110,110). If crUpperTolerance is (10,25,20), the smallest value of that triplet (10) will be used to create the upper stopping point of (135,135,135).

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.

To set the method used when combining the new and existing regions, call LBitmapRgn::SetRgnCombineMode. To determine the current method used when combining regions, call LBitmapRgn::GetRgnCombineMode.

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.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.

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.

See Also

Functions:

LBitmapRgn::SetRgnBorder, LBitmapRgn::SetRgnCombineMode, LBitmapRgn::GetRgnCombineMode, LBitmapRgn::SetRgnColorHSVRange, LBitmapRgn::SetRgnColorRGBRange

Topics:

Raster Image Functions: Creating and Using a Region

 

Defining and Using a Bitmap Region

 

Using Color Values in LEADTOOLS

 

Saving a Region

Example

L_VOID MyTestFunction(LBitmapBase L_FAR *pBitmap, HWND hWnd, L_INT x, L_INT y)
{
   LPaint LeadPaint ;
   LBitmapRgn LeadRegion(pBitmap);
   RGNXFORM Xform;
   HDC hDC=NULL;

   pBitmap->PointToBitmap(TOP_LEFT, &x, &y);
   LeadRegion.SetRgnMagicWand(x, y, (20,30,15),(15,30,10));

   LeadRegion.GetRgnXForm(&Xform);
   Xform.uViewPerspective = TOP_LEFT;

   hDC = GetDC(hWnd);
   LeadPaint.SetDC(hDC) ;
   LeadPaint. FrameRgn(L_FRAME_MOVING0,&Xform) ;

   ReleaseDC(hWnd, hDC);
}