LBitmapBase::EnableUseLUT

#include "ltwrappr.h"

L_BOOL LBitmapBase::EnableUseLUT(bEnable = TRUE)

L_BOOL bEnable;

/* flag that indicates whether to enable the LUT */

Enables or disables the use of LUT.

Parameter

Description

bEnable

Flag that indicates when the LUT is used. Possible values are

 

Value

Meaning

 

TRUE

The LUT is used in all image processing functions, including save. (default).

 

FALSE

The LUT is used only when painting. It is ignored when an image processing function is applied or when a file is saved.

Returns

The previous setting.

Required DLLs and Libraries

LTDIS
LTFIL

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::WindowLevelFillLUT, LBitmap::WindowLevelBitmap, LBitmap::Invert, Class Members

Topics:

Raster Image Functions: Palettes

 

Raster Image Functions: Displaying and Printing

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LBitmapBase__EnableUseLUTExample()
{
   
   RGBQUAD * pLUT;
   L_INT nRet;
   L_INT nMin, nMax;
   L_INT nLowBit, nHighBit;
   LBitmap myBitmap;
   L_INT nLUTLen = 0;
   LSettings::UnlockSupport(L_SUPPORT_MEDICAL, L_KEY_MEDICAL);
   nRet =myBitmap.Load(MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Beauty16.jpg")),16);
   if(nRet !=SUCCESS)
      return nRet;
   nRet =myBitmap.GetMinMaxBits(&nLowBit,&nHighBit);
   if(nRet !=SUCCESS)
      return nRet;
   nRet =myBitmap.GetMinMaxVal(&nMin, &nMax);
   if(nRet !=SUCCESS)
      return nRet;
   /* allocate the lookup table */
   nLUTLen = 1<<(nHighBit - nLowBit + 1);
   pLUT = (RGBQUAD *)malloc(sizeof(RGBQUAD) * nLUTLen);
  /* fill the LUT with a color gradient */
   /* fill the LUT with a color gradient */
   nRet =myBitmap.WindowLevelFillLUT((RGBQUAD *)pLUT,
                              nLUTLen,
                              RGB(255,0,0), /* RED */
                              RGB(0,0,255), /* BLUE */
                              nLowBit, /* Starting value */
                              nLUTLen, /* Ending value */
                              nLowBit, /* Bitmap's LowBit */
                              nHighBit, /* Bitmap's HighBit */
                              nMin, /* Bitmap's MinVal */
                              nMax, /* Bitmap's MaxVal */
                              0, /*nFactor*/ 
      FILLLUT_INSIDE | FILLLUT_LINEAR) /* Fill Inside range */;
   
   if(nRet !=SUCCESS)
      return nRet;
   myBitmap.GetHandle()->LUTLength = nLUTLen;
   myBitmap.GetHandle()->pLUT = (RGBQUAD *)GlobalAllocPtr(GHND,sizeof(RGBQUAD) * nLUTLen);
   memcpy(myBitmap.GetHandle()->pLUT,pLUT,sizeof(RGBQUAD) * nLUTLen);
   myBitmap.EnableUseLUT(TRUE);
   nRet =myBitmap.ColorRes(24,CRF_BYTEORDERBGR|CRF_FLOYDSTEINDITHERING);
   if(nRet !=SUCCESS)
      return nRet;
   /* free the table */
    free(pLUT);
   
   if(myBitmap.GetHandle()->pLUT)
   {
      GlobalFree(myBitmap.GetHandle()->pLUT);
      myBitmap.GetHandle()->LUTLength = 0;
   }
   return SUCCESS;
}