ApplyVOILUT2 Example for C++ 5.0 and later
int CTestImgProcView::TestVOI2LUT(BOOL bLinear)
{
SAFEARRAYBOUND sabFldData[1];
VARIANT vData;
int nRet;
sabFldData[0].cElements = 4096;
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->ApplyLinearVOILUT(m_LeadRasterView.GetRaster(), 0, 0.5, 0);
}
else
{
for(int i = 0; i < 4096; ++i)
{
if(i<30)
{
ix[0] = 0;
data = 0;
hr = SafeArrayPutElement(psaFieldData, ix, &data);
}
else
if (i > 630)
{
ix[0] = 630;
data = 630;
hr = SafeArrayPutElement(psaFieldData, ix, &data);
}
else
{
ix[0] = i;
data = i;
hr = SafeArrayPutElement(psaFieldData, ix, &data);
}
}
VariantInit(&vData);
V_VT(&vData) = VT_ARRAY | VT_I4;
vData.parray = psaFieldData;
m_pRasterProc->ApplyVOILUT2(m_LeadRasterView.GetRaster(), vData, 0, 0);
}
return nRet;
}