LBitmap::ShiftData

#include "ltwrappr.h"

virtual L_INT LBitmap::ShiftData (pSrcBitmap, uSrcLowBit, uSrcHighBit, uDstLowBit, uDstBitsPerPixel, uFlags = 0)

virtual L_INT LBitmap::ShiftData (plSrcBitmap, uSrcLowBit, uSrcHighBit, uDstLowBit, uDstBitsPerPixel, uFlags = 0)

pBITMAPHANDLE pSrcBitmap;

pointer to the source bitmap handle

L_UINT uSrcLowBit;

position of the starting bit of the mask

L_UINT uSrcHighBit;

length of the mask

L_UINT uDstLowBit;

placement of the mask in pDstBitmap

L_UINT uDstBitsPerPixel;

bits per pixel for the destination bitmap

LBitmapBase *plSrcBitmap;

pointer to the source bitmap object

L_UINT32 uFlags;

flags

Selects a specified number of bits from an 8, 12 or 16-bit grayscale bitmap into a mask and places the mask in a new 8, 12 or 16-bit grayscale bitmap.

Parameter

Description

pSrcBitmap

Pointer to the source bitmap that will contain the result of the function. The user should free the bitmap before passing it to the function.

uSrcLowBit

Position of the start bit that will construct the mask. The position is a zero-based number.

uSrcHighBit

Position of the end bit. This is inclusive (it is part of the mask). The value should not be less than uSrcLowBit. You can also pass 1, which is interpreted as "highest bit" (pSrcBitmap->BitsPerPixel 1).

uDstLowBit

The bit position where the selected mask will be copied into the pDstBitmap.

uDstBitsPerPixel

Bits per pixel for the destination bitmap. The allowed values are 8, 12, or 16

plSrcBitmap

Pointer to the source bitmap object that will contain the result of the function. The user should free the bitmap before passing it to the function.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The function is used mainly as a visualization aid. You can select certain bits of the supported type bitmap and display them in another bitmap.

You can use this function for other purposes than visualization. For example, lets say you loaded a 16-bit file that has the pixels in Motorola format (where the high and low bytes are swapped). You can swap the high and low 8 bits for each pixel by calling this function twice and OR-ing the results.

The pDstBitmap should not be allocated when calling this function. You should free the allocated bitmap before calling this function. When the function returns successfully the pDstBitmap will be an 8, 12 or 16-bit grayscale.

For 8, 12 and 16-bit grayscale bitmaps, the uSrcLowBit can range from 0 to 7, 0 to 11, and 0 to 15 respectively. However if this value exceeded the range then the function will not return an error, and the pDstBitmap will be a pure black bitmap.

The uSrcHighBit must be greater than or equal to uSrcLowBit. The function will return an invalid parameter error if uSrcHighBit < uSrcLowBit.

The uDstLowBit can range from 0 to uDstBitsPerPixel 1. If you pass greater values for uDstLowBit, the function will not return an error, but pDstBitmap will become a pure black bitmap.

The following example shows you how to treat a 16-bit grayscale bitmap:

In a16-bit grayscale bitmap, the bits are ordered as b15 b14 b13 ... b2 b1 b0. You can choose the bit from where to start moving the bits.

For example, if the mask starts at the fourth bit (b3), with a length equal to 6 bits, the destination starting position is 4 and we want to create an 8-bit destination bitmap:

uSrcLowBit = 3 
uSrcHighBit = 8 
uDstLowBit = 4 
uDstBitsPerPixel = 8 
Source bitmap (pSrcBitmap): 
-------------------  
b15 b14 b13 b12 b11 b10 b9 |b8 b7 b6 b5 b4 b3| b2 b1 b0 
-------------------   
0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1  
Destination bitmap (pDstBitmap): 
-------------   
   |b7 b6 b5 b4| b3 b2 b1 b0  
    -------------  
   0 0 1 1 0 0 0 0  

You can notice that b7 and b8 of pSrcBitmap are truncated in the bitmap object since there is no space for them.

To update a status bar or detect a user interrupt during execution of this function, refer to LBase::EnableStatusCallback.

This function supports 8, 12 and 16-bit grayscale bitmaps only. Support for 12 and 16-bit grayscale images are available only in the Document/Medical toolkits. It also can process the whole image or a region of the image. If a bitmap has a region, the effect is applied only to the region.

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.

See Also

Functions:

LBitmap::AdjustTint. LBitmap::ColorHalfTone, LBitmap::SelectData, LBitmap::ColorizeGray.

Topics:

Raster Image Functions: Modifying Intensity Values

 

Grayscale Images

 

Color Halftones and Halftone Images

 

Raster Image Functions: Working with Color Halftones, Halftones, and Grayscale Images

 

Raster Image Functions: Correcting Colors

Example

L_INT LBitmap__ShiftDataExample(LBitmap *pLeadBitmap, LBitmap *pSrcBitmap)  
{ 
   L_INT nRet; 
   /* This example applies Shifting. */ 
   /* Move 5 bits starting from bit 2 into the high 8-bits of the destination bitmap */ 
   nRet =pLeadBitmap->ShiftData (pSrcBitmap,  
                                 2 /* uSrcLowBit */,  
                                 6 /* uSrcHighBit*/,  
                                 3 /* uDstLowBit */,  
                                 8 /* uDstBitsPerPixel */ ); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   pLeadBitmap->Free (); 
 
   // Now we have the resulting image in pLeadBitmap 
    
   return SUCCESS; 
} 
Help Version 20.0.2020.4.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help