LBitmapRgn::SetRgnBorder

Summary

Creates a region of pixels with values that fall within a range defined by the value of a specific pixel and a lower and upper tolerance value but are not equal to crBorderColor.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmapRgn::SetRgnBorder(x, y, crBorderColor, crLowerTolerance, crUpperTolerance)

Parameters

L_INT x

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

L_INT y

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

COLORREF crBorderColor

Border color.

COLORREF crLowerTolerance

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

COLORREF crUpperTolerance

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

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

For color bitmaps:

If the value of the pixel at (x, y) is (125, 125, 125) and crLowerTolerance is (20,30,15), then the lower stopping point is (105, 95, 110). If crUpperTolerance is (20,30,15), then the upper stopping point is (145,155,140). In this case, the pixels with values between (105,95,110) and (145,155,140) are non-border pixels and will be included in the region. Any pixel with a value outside this range or equal to crBorderColor is considered a border pixel.

For gray scale bitmaps:

The minimum channel tolerance value of crLowerTolerance will be used to set the lower stopping point, and the minimum channel tolerance 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). In this case, the pixels with values between (110, 110, 110) and (135,135,135) are non-border pixels and will be included in the region. Any pixel with a value outside this range or equal to crBorderColor is considered a border pixel.

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.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LBitmapRgn__SetRgnBorderExample(LBitmap * plBitmap, HWND hWnd, L_INT x, 
                                                       L_INT y, COLORREF crBorder) 
{ 
  
   L_INT nRet;  
   RGNXFORM Xform;  
   HDC hDC=NULL;  
   LPaint LeadPaint ;  
   LBitmapRgn LeadRegion(plBitmap);  
 
   plBitmap->PointToBitmap(TOP_LEFT, &x, &y);  
 
   if(plBitmap->HasRgn()) 
   { 
      plBitmap->Region()->SetRgnCombineMode(L_RGN_OR);  
      nRet = plBitmap->Region()->SetRgnBorder(x, y,crBorder, (20,30,15),(15,30,10));  
   } 
 
   else 
   { 
      plBitmap->Region()->SetRgnCombineMode(L_RGN_SET);  
      nRet = plBitmap->Region()->SetRgnBorder(x, y,crBorder, (20,30,15),(15,30,10));  
   } 
 
   if(nRet == SUCCESS)  
   { 
      if(plBitmap->HasRgn()) 
      { 
         ReleaseDC(hWnd, hDC);  
         LeadRegion.GetRgnXForm(&Xform);  
         Xform.uViewPerspective = TOP_LEFT;  
         Xform.nXScalarNum=1;  
         Xform.nXScalarDen=1;  
         Xform.nYScalarNum=1;  
         Xform.nYScalarDen=1;  
         Xform.nXOffset=0;  
         Xform.nYOffset=0;  
  
         hDC =GetDC(hWnd);  
         LeadPaint.SetDC(hDC) ;  
         LeadPaint. FrameRgn(L_FRAME_MOVING0,&Xform) ;  
         ReleaseDC(hWnd, hDC);  
      } 
      else 
      { 
         MessageBox(hWnd, TEXT("no rgn"), TEXT("error"), MB_OK);  
         return nRet; 
      } 
   } 
 
   return SUCCESS; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.