L_ClearNegativePixels

#include "l_bitmap.h"

L_LTKRN_API L_INT L_ClearNegativePixels(pBitmap)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

Sets all pixels with negative color values to 0.

Parameter

Description

pBitmap

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

Returns

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.

PROGRAMMING TIP: call L_ClearNegativePixels right after L_LoadBitmap.

Regions are not supported on the Windows CE platform.

Required DLLs and Libraries

LTKRN

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_LoadBitmap, L_ClearBitmap

Topics

Raster Image Functions: Getting and Setting Pixel Values

Example

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

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
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 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help