ColorModel cm = null;
WritableRaster wr = null;
if (depth() == IPL_DEPTH_8U || depth() == IPL_DEPTH_8S) {
cm = new ComponentColorModel(cs, alpha,
false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
wr = Raster.createWritableRaster(new ComponentSampleModel(
DataBuffer.TYPE_BYTE, width(), height(), nChannels(), widthStep(),
offsets), null);
} else if (depth() == IPL_DEPTH_16U) {
cm = new ComponentColorModel(cs, alpha,
false, Transparency.OPAQUE, DataBuffer.TYPE_USHORT);
wr = Raster.createWritableRaster(new ComponentSampleModel(
DataBuffer.TYPE_USHORT, width(), height(), nChannels(), widthStep()/2,
offsets), null);
} else if (depth() == IPL_DEPTH_16S) {
cm = new ComponentColorModel(cs, alpha,
false, Transparency.OPAQUE, DataBuffer.TYPE_SHORT);
wr = Raster.createWritableRaster(new ComponentSampleModel(
DataBuffer.TYPE_SHORT, width(), height(), nChannels(), widthStep()/2,
offsets), null);
} else if (depth() == IPL_DEPTH_32S) {
cm = new ComponentColorModel(cs, alpha,
false, Transparency.OPAQUE, DataBuffer.TYPE_INT);
wr = Raster.createWritableRaster(new ComponentSampleModel(
DataBuffer.TYPE_INT, width(), height(), nChannels(), widthStep()/4,
offsets), null);
} else if (depth() == IPL_DEPTH_32F) {
cm = new ComponentColorModel(cs, alpha,
false, Transparency.OPAQUE, DataBuffer.TYPE_FLOAT);
wr = Raster.createWritableRaster(new ComponentSampleModel(
DataBuffer.TYPE_FLOAT, width(), height(), nChannels(), widthStep()/4,
offsets), null);
} else if (depth() == IPL_DEPTH_64F) {
cm = new ComponentColorModel(cs, alpha,
false, Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE);
wr = Raster.createWritableRaster(new ComponentSampleModel(
DataBuffer.TYPE_DOUBLE, width(), height(), nChannels(), widthStep()/8,
offsets), null);
}
bufferedImage = new BufferedImage(cm, wr, false, null);