dataType = DT_DOUBLE;
dataArray = data;
}
public LCMSImageLayout(BufferedImage image) {
ShortComponentRaster shortRaster;
IntegerComponentRaster intRaster;
ByteComponentRaster byteRaster;
switch (image.getType()) {
case BufferedImage.TYPE_INT_RGB:
pixelType = PT_ARGB_8;
isIntPacked = true;
break;
case BufferedImage.TYPE_INT_ARGB:
pixelType = PT_ARGB_8;
isIntPacked = true;
break;
case BufferedImage.TYPE_INT_BGR:
pixelType = PT_ABGR_8;
isIntPacked = true;
break;
case BufferedImage.TYPE_3BYTE_BGR:
pixelType = PT_BGR_8;
break;
case BufferedImage.TYPE_4BYTE_ABGR:
pixelType = PT_ABGR_8;
break;
case BufferedImage.TYPE_BYTE_GRAY:
pixelType = PT_GRAY_8;
break;
case BufferedImage.TYPE_USHORT_GRAY:
pixelType = PT_GRAY_16;
break;
default:
// TODO: Add support for some images having
// SinglePixelPackedModel and ComponentSampleModel
throw new IllegalArgumentException(
"CMMImageLayout - bad image type passed to constructor");
}
width = image.getWidth();
height = image.getHeight();
switch (image.getType()) {
case BufferedImage.TYPE_INT_RGB:
case BufferedImage.TYPE_INT_ARGB:
case BufferedImage.TYPE_INT_BGR:
intRaster = (IntegerComponentRaster)image.getRaster();
nextRowOffset = intRaster.getScanlineStride()*4;
offset = intRaster.getDataOffset(0)*4;
dataArray = intRaster.getDataStorage();
dataType = DT_INT;
break;
case BufferedImage.TYPE_3BYTE_BGR:
case BufferedImage.TYPE_4BYTE_ABGR:
byteRaster = (ByteComponentRaster)image.getRaster();
nextRowOffset = byteRaster.getScanlineStride();
offset = byteRaster.getDataOffset(0);
dataArray = byteRaster.getDataStorage();
dataType = DT_BYTE;
break;
case BufferedImage.TYPE_BYTE_GRAY:
byteRaster = (ByteComponentRaster)image.getRaster();
nextRowOffset = byteRaster.getScanlineStride();
offset = byteRaster.getDataOffset(0);
dataArray = byteRaster.getDataStorage();
dataType = DT_BYTE;
break;
case BufferedImage.TYPE_USHORT_GRAY:
shortRaster = (ShortComponentRaster)image.getRaster();
nextRowOffset = shortRaster.getScanlineStride()*2;
offset = shortRaster.getDataOffset(0) * 2;
dataArray = shortRaster.getDataStorage();
dataType = DT_SHORT;
break;
}
}