ApplyModalityLUT2 Example for C++ 5.0 and later
int CTestImgProcView::TestModalityLUT(BOOL bLinear)
{
SAFEARRAYBOUND sabFldData[1];
VARIANT vData;
int nRet;
sabFldData[0].cElements = 65536;
sabFldData[0].lLbound = 0;
HRESULT hr;
SAFEARRAY * psaFieldData = SafeArrayCreate(VT_VARIANT | VT_I4, 1, sabFldData);
long ix[1]; //For the position of the elements within the array.
long data;
if (bLinear)
{
nRet = m_pRasterProc->ApplyLinearModalityLUT(m_LeadRasterView.GetRaster(), 0, 0.5, 0);
}
else
{
for(int i = 0; i < 65536; ++i)
{
ix[0] = i;
data = i/2;
hr = SafeArrayPutElement(psaFieldData, ix, &data);
}
VariantInit(&vData);
V_VT(&vData) = VT_ARRAY | VT_I4;
vData.parray = psaFieldData;
m_pRasterProc->ApplyModalityLUT2(m_LeadRasterView.GetRaster(), vData, 0, 0);
}
return nRet;
}