L_CreateMaskFromBitmapRgn

#include "l_bitmap.h"

L_LTDIS_API L_INT L_CreateMaskFromBitmapRgn(pBitmap, pMask, uStructSize)

Creates a 1-bit mask image from the region that is defined in the source bitmap.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the source bitmap, where the region is defined.

pBITMAPHANDLE pMask

Pointer to the bitmap handle referencing the destination bitmap, which will be updated with a 1-bit, black-and-white image, where pixels from the region are white, and all others are black.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).

Returns

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

Comments

A bitmap region is an area of interest within a bitmap. A bitmap can have only one region at a time, but the region can be complex, including, for example, multiple noncontiguous shapes. For more information, refer to Creating a Bitmap Region.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example loads an image, sets a color region using black,
and then creates a 1-bit mask image from that bitmap.

L_INT CreateMaskFromBitmapRgnExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap; /* Bitmap handle that holds the loaded bitmap */ 
   BITMAPHANDLE MaskBitmap; /* Bitmap handle that holds the mask bitmap */ 
 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL ); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = L_SetBitmapRgnColor (&LeadBitmap, RGB( 0,0,0 ), L_RGN_SET ); 
   if(nRet != SUCCESS) 
      return nRet; 
   nRet = L_CreateMaskFromBitmapRgn(&LeadBitmap, &MaskBitmap, sizeof(BITMAPHANDLE)); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &MaskBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   L_FreeBitmap(&LeadBitmap); 
   L_FreeBitmap(&MaskBitmap); 
   return SUCCESS; 
} 

Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

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