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.

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

Windows 2000 / XP/Vista, Windows CE.

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.

 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 (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\IMAGE1.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(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\Result.TIF"), &LeadBitmap, FILE_BMP, 24, 0, NULL);
   if(nRet != SUCCESS)
   {
      L_FreeBitmap(&LeadBitmap);
      return nRet;
   }

   L_FreeBitmap(&LeadBitmap);

   return SUCCESS;
}