L_ConvertBitmapSignedToUnsigned

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_ConvertBitmapSignedToUnsigned(pBitmap, uShift, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the bitmap handle

L_UINT uShift;

shifting option

L_UINT32 uFlags;

flags

Converts a signed bitmap to unsigned.

Parameter Description
pBitmap Pointer to the bitmap handle referencing the bitmap.
uShift Flag that indicates how the shift will be done. Possible values are:
  Value Meaning
  SHIFT_ZERO_TO_CENTER [0x0000] Shift by 32768 (16-bit images) or by 2048 (12-bit images)
  SHIFT_MIN_TO_ZERO [0x0001] Shift all image data to make minimum value in the image 0 and the maximum value to the maximum possible value (65535 for 16-bit, 4095 for 12-bit).
  SHIFT_NEG_TO_ZERO [0x0002] Set all the negative pixels to 0 and leave the positive pixels unchanged. (Achieves the same result as L_ClearNegativePixels).
  SHIFT_RANGE_ONLY [0x0003] Shift data by adding half the range to each pixel without changing bits outside the (LowBit-HighBit) range.
  SHIFT_RANGE_PROCESS_OUTSIDE [0x0004] Shift data by adding half the range to each pixel and set to zero all bits outside the (LowBit-HighBit) range.
uFlags Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

If the 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. To use this bitmap correctly the negative pixels should be converted, if it contains negative pixels (if pBitmap->Flags.Signed is TRUE).

If the pBitmap->Flags.Signed is set to TRUE, this function will shift the color values in the Bitmap according to the uShift parameter.

The function will also update the MinVal and MaxVal members of the BITMAPHANDLE.

This function supersedes L_ClearNegativePixels.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Required DLLs and Libraries

LTIMGCOR

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_ClearNegativePixels, L_ConvertBitmapUnsignedToSigned

Topics:

Processing an Image

 

Raster Image Functions: Getting and Setting Pixel Values

Example

L_INT ConvertBitmapSignedToUnsignedExample(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 = 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("IMAGE1.dcm")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, &LoadFileOption, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* clear negative pixels if signed */ 
   if(LeadBitmap.Flags.Signed) 
   { 
      nRet = L_ConvertBitmapSignedToUnsigned(&LeadBitmap, SHIFT_NEG_TO_ZERO, 0); 
      if(nRet !=SUCCESS) 
         return nRet; 
   } 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   if(LeadBitmap.Flags.Allocated)   
      L_FreeBitmap(&LeadBitmap);   
   return SUCCESS; 
} 

Help Version 20.0.2018.2.25
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help