bytes[i] = new byte[pixels];
bands[i].get(bytes[i]);
}
imgBuffer = new DataBufferByte(bytes, pixels);
buffer_type = DataBuffer.TYPE_BYTE;
sampleModel = new BandedSampleModel(buffer_type,
xsize, ysize, xsize, banks, offsets);
data_type = (poBand.GetRasterColorInterpretation() ==
gdalconstConstants.GCI_PaletteIndex)?
BufferedImage.TYPE_BYTE_INDEXED : BufferedImage.TYPE_BYTE_GRAY;
} else if(buf_type == gdalconstConstants.GDT_Int16) {
short[][] shorts = new short[bandCount][];
for(int i = 0; i < bandCount; i++) {
shorts[i] = new short[pixels];
bands[i].asShortBuffer().get(shorts[i]);
}
imgBuffer = new DataBufferShort(shorts, pixels);
buffer_type = DataBuffer.TYPE_USHORT;
sampleModel = new BandedSampleModel(buffer_type,
xsize, ysize, xsize, banks, offsets);
data_type = BufferedImage.TYPE_USHORT_GRAY;
} else if(buf_type == gdalconstConstants.GDT_Int32) {
int[][] ints = new int[bandCount][];
for(int i = 0; i < bandCount; i++) {
ints[i] = new int[pixels];
bands[i].asIntBuffer().get(ints[i]);
}
imgBuffer = new DataBufferInt(ints, pixels);
buffer_type = DataBuffer.TYPE_INT;
sampleModel = new BandedSampleModel(buffer_type,
xsize, ysize, xsize, banks, offsets);
data_type = BufferedImage.TYPE_CUSTOM;
}
WritableRaster raster = Raster.createWritableRaster(sampleModel, imgBuffer, null);