ShiftData method (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int ShiftData(TBitmapHandle SrcBitmap, unsigned uSrcLowBit, unsigned uSrcHighBit, unsigned uDstLowBit, unsigned uDstBitsPerPixel);

Delphi Syntax

Function ShiftData (SrcBitmap: TBitmapHandle; uSrcLowBit: L_UINT; uSrcHighBit: L_UINT; uDstLowBit: L_UINT; uDstBitsPerPixel: L_UINT): L_INT;

Overview

Refer to Grayscale Images

Remarks

(Medical only) Selects a specified number of bits from an 8, 12 or 16-bit grayscale bitmap, creates a mask using these bits, and places the mask in a new 8, 12 or 16-bit grayscale bitmap.

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

You can use this method for other purposes than visualization. For example, let’s 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 method twice and OR-ing the results.

When the method returns successfully the destination bitmap (the bitmap currently loaded in the Main Control and accessed through the Bitmap property (Main Control)) 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 method will not return an error, and the Bitmap property (Main Control) will contain a pure black bitmap.

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

The uDstLowBit parameter can range from 0 to uDstBitsPerPixel -1. If you pass greater values for uDstLowBit, the method will not return an error, but the destination bitmap (the bitmap currently loaded in the Main Control and accessed through the Bitmap property (Main Control)) 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 (SrcBitmap):

------------------- 

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 (Loaded bitmap):

-------------  

   |b7 b6 b5 b4| b3 b2 b1 b0 

    ------------- 

   0 0 1 1 0 0 0 0 

Notice that b7 and b8 of SrcBitmap are truncated in the destination bitmap since there is no space for them.

This method 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 method does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this method.

See Also

Elements:

SelectData method, ColorizeGray method.

Topics:

Raster Images: Doing Color Expansion or Reduction