final ColorInterpretation colorInterpretation=TypeMap.getColorInterpretation(cm, i);
if(colorInterpretation==null)
throw new IOException("Unrecognized sample dimension type");
// sample dimension type
final SampleDimensionType st=TypeMap.getSampleDimensionType(sm, i);
// set some no data values, as well as Min and Max values
final double noData;
double min=-Double.MAX_VALUE,max=Double.MAX_VALUE;
if(backgroundValues!=null)
{
// sometimes background values are not specified as 1 per each band, therefore we need to be careful
noData= backgroundValues[backgroundValues.length > i ? i:0];
}
else
{
if(st.compareTo(SampleDimensionType.REAL_32BITS)==0)
noData= Float.NaN;
else
if(st.compareTo(SampleDimensionType.REAL_64BITS)==0)
noData= Double.NaN;
else
if(st.compareTo(SampleDimensionType.SIGNED_16BITS)==0)
{
noData=Short.MIN_VALUE;
min=Short.MIN_VALUE;
max=Short.MAX_VALUE;
}
else
if(st.compareTo(SampleDimensionType.SIGNED_32BITS)==0)
{
noData= Integer.MIN_VALUE;
min=Integer.MIN_VALUE;
max=Integer.MAX_VALUE;
}
else
if(st.compareTo(SampleDimensionType.SIGNED_8BITS)==0)
{
noData= -128;
min=-128;
max=127;
}
else
{
//unsigned
noData= 0;
min=0;
// compute max
if(st.compareTo(SampleDimensionType.UNSIGNED_1BIT)==0)
max=1;
else
if(st.compareTo(SampleDimensionType.UNSIGNED_2BITS)==0)
max=3;
else
if(st.compareTo(SampleDimensionType.UNSIGNED_4BITS)==0)
max=7;
else
if(st.compareTo(SampleDimensionType.UNSIGNED_8BITS)==0)
max=255;
else
if(st.compareTo(SampleDimensionType.UNSIGNED_16BITS)==0)
max=65535;
else
if(st.compareTo(SampleDimensionType.UNSIGNED_32BITS)==0)
max=Math.pow(2, 32)-1;
}