WindowLevel example for C++ 5.0 and later

ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL,
                 IID_ILEADRasterProcess, (void**)&pRasterProc);
//WindowLevel for Display
pRasterProc->Grayscale(m_LEADRasterView1.GetRaster(), 12);//Grayscale image to 12-bit
m_LEADRasterView1.GetRaster().SetLevelLowBit(8);//use 4 most significant bits
m_LEADRasterView1.GetRaster().SetLevelHighBit(11);
m_LEADRasterView1.WindowLevel();
pRasterProc->Release();


ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL,
                 IID_ILEADRasterProcess, (void**)&pRasterProc);
//WindowLevel image processing
pRasterProc->Grayscale(m_LEADRasterView1.GetRaster(), 12);//Grayscale image to 12-bit
m_LEADRasterView1.GetRaster().SetLevelLowBit(8);//use 4 most significant bits
m_LEADRasterView1.GetRaster().SetLevelHighBit(11);
pRasterProc->WindowLevel(m_LEADRasterView1.GetRaster());
pRasterProc->Release();


//This example loads a 16-bit grayscale, fills the window level lookup table,
//and window levels the bitmap for display only
long i;
ILEADRasterIO *pRasterIO=NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL,
                 IID_ILEADRasterIO, (void**)&pRasterIO);
ILEADRasterProcess *pRasterProc=NULL;
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL,
                 IID_ILEADRasterProcess, (void**)&pRasterProc);
//Load a 16-bit grayscale image
pRasterIO->Load(m_LEADRasterView1.GetRaster(),
                "d:\\lead14\\dist\\images\\dicom\\image2.dic",
                0, 0, 1);
m_LEADRasterView1.SetAutoRepaint(FALSE);

//Use all bits
m_LEADRasterView1.GetRaster().SetLevelLowBit(0);
m_LEADRasterView1.GetRaster().SetLevelHighBit(m_LEADRasterView1.GetRaster().GetBitmapBits() - 1);

m_LEADRasterView1.GetRaster().GetMinMaxBits();
m_LEADRasterView1.GetRaster().GetMinMaxVal();

//Set LUT so the range is from pure blue to pure red
for(i=m_LEADRasterView1.GetRaster().GetMinVal(); i<m_LEADRasterView1.GetRaster().GetMaxVal();i++)
   m_LEADRasterView1.GetRaster().SetLevelLUT(i, RGB(i % 256, 0, 256 - i % 256));
    
//Window level for display only--leave the bitmap data unchanged
m_LEADRasterView1.WindowLevel();
m_LEADRasterView1.ForceRepaint();
pRasterIO->Release();
pRasterProc->Release();