Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_SetBitmapRgnBorder

Show in webframe

#include "l_bitmap.h"

L_LTDIS_API L_INT L_SetBitmapRgnBorder(pBitmap, x, y, crBorderColor, crLowerTolerance, crUpperTolerance, uCombineMode);

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT x;

/* x coordinate */

L_INT y;

/* y coordinate */

L_COLORREF crBorderColor;

/* border color */

L_COLORREF crLowerTolerance;

/* upper tolerance values */

L_COLORREF crUpperTolerance;

/* upper tolerance values */

L_UINT uCombineMode;

/* action to take regarding the existing region */

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.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap.

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.

crBorderColor

Border color.

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.

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.

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.

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, Linux.

See Also

Functions:

L_SetBitmapRgnColor, L_SetBitmapRgnMagicWand

Topics:

Raster Image Functions: Creating and Using a Region

 

Creating a Bitmap Region

 

Using Color Values in LEADTOOLS

 

Saving a Region

Example

L_INT SetBitmapRgnBorderExample(pBITMAPHANDLE  pBitmap,
                                               L_HWND           hWnd,
                                               L_INT          x,
                                               L_INT          y,
                                               COLORREF       crBorder)
{
   L_INT       nRet;
   RGNXFORM    XForm;

   L_PointToBitmap(pBitmap, TOP_LEFT, &x, &y);
   if(L_BitmapHasRgn(pBitmap))
      nRet = L_SetBitmapRgnBorder(pBitmap, x, y,crBorder, (20,30,15),(15,30,10), L_RGN_OR);
   else
      nRet = L_SetBitmapRgnBorder(pBitmap, x, y,crBorder, (20,30,15),(15,30,10), L_RGN_SET);

 if(nRet == SUCCESS)
   {
      if(L_BitmapHasRgn(pBitmap))
      {
         HDC hDC=GetDC(hWnd);
         XForm.uViewPerspective=TOP_LEFT;
         XForm.nXScalarNum=1;
         XForm.nXScalarDen=1;
         XForm.nYScalarNum=1;
         XForm.nYScalarDen=1;
         XForm.nXOffset=0;
         XForm.nYOffset=0;

         L_FrameBitmapRgn(hDC, pBitmap, &XForm, 3);
         ReleaseDC(hWnd, hDC);
      }
      else
      {
         MessageBox(hWnd, TEXT("no rgn"), TEXT("error"), MB_OK);
         return nRet;
      }
   }
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.