L_ShiftBitmapData

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_ShiftBitmapData(pDstBitmap, pSrcBitmap, uSrcLowBit, uSrcHighBit, uDstLowBit, uDstBitsPerPixel, uFlags)

pBITMAPHANDLE pDstBitmap;

/* pointer to the destination bitmap handle */

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 */

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.

This function is available in the Document and Medical Imaging 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.

Parameter

Description

pDstBitmap

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

pSrcBitmap

Pointer to the source bitmap handle referencing the 8, 12 or 16-bit grayscale bitmap. pSrcBitmap will not be affected.

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

uFlags

Reserved for future use. Must be 0.

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

Windows 2000 / XP/Vista.

See Also

Functions:

L_SelectBitmapData, L_ColorizeGrayBitmap, L_AdjustBitmapTint, L_ColorHalfToneBitmap

Topics:

Raster Image Functions: Modifying Intensity Values

 

Grayscale Images

 

Color Halftone and Halftone Images

 

Raster Image Functions: Correcting Colors

Example

This example loads a bitmap and applies Shifing.

#if defined (LEADTOOLS_V16_OR_LATER)
 L_INT ShiftBitmapDataExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
   BITMAPHANDLE DstBitmap;     /* Bitmap handle to hold the result. */

   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\GrayIMAGE1.tif"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, NULL); 
   if(nRet !=SUCCESS)
      return nRet;

   /* Move 5 bits starting from bit 2 into the high bits of the destination bitmap */
   nRet = L_ShiftBitmapData (&DstBitmap, &LeadBitmap,
                             2 /* uSrcLowBit */, 
                             6 /* uSrcHighBit*/, 
                             3 /* uDstLowBit */, 
                             8 /* uDstBitsPerPixel */ , 0); 
   if(nRet !=SUCCESS)
      return nRet;

   // Now we have the resulting image in DstBitmap
   nRet = L_SaveBitmap(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Result.BMP"), &DstBitmap, FILE_BMP, 24, 0, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   if(DstBitmap.Flags.Allocated)
      L_FreeBitmap(&DstBitmap);  
   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  
   return SUCCESS;
}
#else
 L_INT ShiftBitmapDataExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */
   BITMAPHANDLE DstBitmap;     /* Bitmap handle to hold the result. */

   /* Load the bitmap, keeping the bits per pixel of the file */
   nRet = L_LoadBitmap (TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\GrayIMAGE1.tif"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, NULL, NULL); 
   if(nRet !=SUCCESS)
      return nRet;

   /* Move 5 bits starting from bit 2 into the high bits of the destination bitmap */
   nRet = L_ShiftBitmapData (&DstBitmap, &LeadBitmap,
                             2 /* uSrcLowBit */, 
                             6 /* uSrcHighBit*/, 
                             3 /* uDstLowBit */, 
                             8 /* uDstBitsPerPixel */ ); 
   if(nRet !=SUCCESS)
      return nRet;

   // Now we have the resulting image in DstBitmap
   nRet = L_SaveBitmap(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Result.BMP"), &DstBitmap, FILE_BMP, 24, 0, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   if(DstBitmap.Flags.Allocated)
      L_FreeBitmap(&DstBitmap);  
   //free bitmap 
   if(LeadBitmap.Flags.Allocated)  
      L_FreeBitmap(&LeadBitmap);  
   return SUCCESS;
}
#endif // LEADTOOLS_V16_OR_LATER