LBitmap::ConvertSignedToUnsigned

Summary

Converts a signed bitmap to unsigned.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::ConvertSignedToUnsigned(uShift, uFlags = 0)

Parameters

L_UINT 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 LBitmapBase::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.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

Value Meaning
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 LBitmapBase::IsPixelsSigned() is TRUE).

If the LBitmapBase::IsPixelsSigned() is 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 Bitmap object.

This function supersedes LBitmapBase::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 only in the Document/Medical 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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LBitmap__ConvertSignedToUnsignedExample(LBitmap * plBitmap) 
 
{ 
   L_INT nRet; 
 
   /* clear negative pixels if signed */ 
 
   if(plBitmap->IsPixelsSigned() )  
   { 
      nRet =plBitmap->ConvertSignedToUnsigned(SHIFT_NEG_TO_ZERO); 
      if(nRet !=SUCCESS) 
         return nRet; 
   } 
   else 
      return FAILURE;    
 
   return SUCCESS; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

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