Here is the code that i have used for window level.:
L_INT nRet;
L_UINT32 x;
L_RGBQUAD* ptmp;
RGBQUAD* pLUT;
L_INT nLowBit;
L_INT nHighBit;
L_INT nLow;
L_INT nHigh;
L_INT nSize;
BITMAPHANDLE pBitmap;
nRet = L_LoadBitmap (TEXT("C:\\Allengers1_1.tif"), &pBitmap, sizeof(BITMAPHANDLE), 16, ORDER_GRAY, NULL, NULL);
nRet = L_GetMinMaxBits(&pBitmap, &nLowBit, &nHighBit,0);
if(nRet != SUCCESS)
{
::MessageBox(NULL,L"Not get Bits",L"Information",MB_OK|MB_ICONINFORMATION);
exit(0);
}
nRet = L_GetMinMaxVal(&pBitmap, &nLow, &nHigh,0);
if(nRet != SUCCESS)
{
::MessageBox(NULL,L"Not Get values",L"Information",MB_OK|MB_ICONINFORMATION);
exit(1);
}
nSize = (L_UINT32)(1L<<(nHighBit - nLowBit + 1));
pLUT = (RGBQUAD *)GlobalAllocPtr(GHND, nSize * sizeof(RGBQUAD));
ptmp = pLUT;
for(x=0;x<nSize/2;x++)
{
ptmp->rgbRed = 0;
ptmp->rgbGreen = 0;
ptmp->rgbBlue = 0;
ptmp->rgbReserved = 0;
ptmp++;
}
for(x=nSize/2;x<nSize;x++)
{
ptmp->rgbRed = ((L_UINT16) ((L_UINT32) (x - nLow) * 0xFFFF / (nHigh - nLow)));
ptmp->rgbGreen = ptmp->rgbRed;
ptmp->rgbBlue = ptmp->rgbGreen;
ptmp->rgbReserved = 0;
ptmp++;
}
nRet = L_WindowLevel( &pBitmap, nLowBit, nHighBit,
pLUT, nSize, WINDOWLEVEL_PAINT | WINDOWLEVEL_PAINT_AND_PROCESSING );
if(nRet != SUCCESS)
{
::MessageBox(NULL,L"Not Success",L"Information",MB_OK|MB_ICONINFORMATION);
exit(7);
}
nRet = L_SaveBitmap(TEXT("C:\\Result.bmp"), &pBitmap, FILE_BMP, 24, 0, NULL);
if(nRet != SUCCESS)
{
::MessageBox(NULL,L"Image not saved",L"Information",MB_OK|MB_ICONINFORMATION);
exit(6);
}
GlobalFreePtr(pLUT);
I am also attaching the result which comes up with the above code. But it is not exactly like the one which we obtained from MainDemo.
Please help me resolve this.
Thanks..