L_ClearNegativePixels

#include "l_bitmap.h"

L_LTKRN_API L_INT L_ClearNegativePixels(pBitmap)

Sets all pixels with negative color values to 0.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap that holds the image data.

Returns

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

Comments

If ELO_SIGNED flag has been set using LOADFILEOPTION, when a file is loaded, the bitmap may contain negative pixel values and LEADTOOLS will paint/process the image incorrectly. In order to use this bitmap correctly, you must call L_ClearNegativePixels. If the ELO_SIGNED flag has not been set, all negative pixels are cleared internally, during the load process. Since some TIFF files are saved with negative values for pixel colors, you should call L_ClearNegativePixels if, after loading a bitmap, pBitmap->Flags.Signed is TRUE.

L_ClearNegativePixels does nothing if Flags.Signed is not set.

💡 TIP

Call L_ClearNegativePixels right after L_LoadBitmap.

Regions are not supported on the Windows CE platform.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example sets the ELO_SIGNED flag in LOADFILEOPTION,
loads a tif file and clears the negative pixels.

L_INT ClearNegativePixelsExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE   LeadBitmap;   /* Bitmap handle to hold the loaded image. */ 
   LOADFILEOPTION LoadFileOption; 
 
   /* enable negative pixels to be loaded from TIFF files */ 
   nRet = L_GetDefaultLoadFileOption(&LoadFileOption, sizeof(LOADFILEOPTION)); 
   if(nRet != SUCCESS) 
      return nRet; 
   LoadFileOption.Flags |= ELO_SIGNED; 
 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image4.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, &LoadFileOption, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* clear negative pixels if signed */ 
   if(LeadBitmap.Flags.Signed) 
   { 
      nRet = L_ClearNegativePixels(&LeadBitmap); 
      if(nRet != SUCCESS) 
      { 
         L_FreeBitmap(&LeadBitmap); 
         return nRet; 
      } 
   } 
 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.TIF")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet != SUCCESS) 
   { 
      L_FreeBitmap(&LeadBitmap); 
      return nRet; 
   } 
 
   L_FreeBitmap(&LeadBitmap); 
 
   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.