I'm looping through an image, reading the pixel values and manipulating them. The pixel value can only be returned as a variant, therefore I'm going to need to use variant.dblVal or .iVal etc to get the value. My program will however encounter most real types, therefore I will need to use .dblVal or .iVal depending on the image. Is there a way of doing this without a hefty switch statement inside my image loop getting in the way? i.e. obtaining the value just using a single statement?
Any help appreciated.
Will
Code:
long i, j;
long ij[2];
VARIANT v;
double getvalM;
ipInRasProps->get_NoDataValue(&vInnodatavalue);
ipOutputRasProps->get_NoDataValue(&vOutNodatavalue);
for (i=0; i<(lHeight - 1); i++)
{
ij[0]=i;
for (j=0; j<(lWidth - 1); j++)
{
ij[1]=j;
ipInputBlock3->GetVal(0, i, j, &v);
getvalM = v.iVal; //here I'd have a switch statement
if ((j + 1) < (lWidth))
SafeArrayPutElement(vSrcPixelArray.parray, ij, &v);
}
}
}
ipOutputBlock = ipOutputBlock3;
ipOutRawPixel->Write(pPnt, ipOutputBlock);