for(int i=0;i<numbits;i++){
bits[i] =
imageDepth;
bankindices[i]
=i;
bandoffsets[i]
=0;
}
ComponentColorModel ccm = new ComponentColorModel(
ColorSpace.getInstance(ColorSpace.CS_sRGB),
bits, //image depth array
hasAlpha,
false,
Transparency.OPAQUE,
DataBuffer.TYPE_USHORT);
BandedSampleModel csm = new BandedSampleModel(
DataBuffer.TYPE_USHORT,
imageWidth, imageHeight,
imageWidth, //scan line stride
bankindices,//bank indices
bandoffsets);//bad offsets
DataBuffer dataBuf = new DataBufferUShort(data, imageWidth*imageHeight);
WritableRaster wr = Raster.createWritableRaster(csm, dataBuf, new Point(0,0));
return new BufferedImage(ccm,
wr, false, null);
}