case BufferedImage.TYPE_USHORT_555_RGB:
sData = createDataSC(bufImg, SurfaceType.Ushort555Rgb, null);
break;
case BufferedImage.TYPE_BYTE_INDEXED:
{
SurfaceType sType;
switch (cm.getTransparency()) {
case OPAQUE:
if (isOpaqueGray((IndexColorModel)cm)) {
sType = SurfaceType.Index8Gray;
} else {
sType = SurfaceType.ByteIndexedOpaque;
}
break;
case BITMASK:
sType = SurfaceType.ByteIndexedBm;
break;
case TRANSLUCENT:
sType = SurfaceType.ByteIndexed;
break;
default:
throw new InternalError("Unrecognized transparency");
}
sData = createDataBC(bufImg, sType, 0);
}
break;
case BufferedImage.TYPE_BYTE_GRAY:
sData = createDataBC(bufImg, SurfaceType.ByteGray, 0);
break;
case BufferedImage.TYPE_USHORT_GRAY:
sData = createDataSC(bufImg, SurfaceType.UshortGray, null);
break;
case BufferedImage.TYPE_BYTE_BINARY:
{
SurfaceType sType;
SampleModel sm = bufImg.getRaster().getSampleModel();
switch (sm.getSampleSize(0)) {
case 1:
sType = SurfaceType.ByteBinary1Bit;
break;
case 2:
sType = SurfaceType.ByteBinary2Bit;
break;
case 4:
sType = SurfaceType.ByteBinary4Bit;
break;
default:
throw new InternalError("Unrecognized pixel size");
}
sData = createDataBP(bufImg, sType);
}
break;
case BufferedImage.TYPE_CUSTOM:
default:
{
Raster raster = bufImg.getRaster();
int numBands = raster.getNumBands();
if (raster instanceof IntegerComponentRaster &&
raster.getNumDataElements() == 1 &&
((IntegerComponentRaster)raster).getPixelStride() == 1)
{
SurfaceType sType = SurfaceType.AnyInt;
if (cm instanceof DirectColorModel) {
DirectColorModel dcm = (DirectColorModel) cm;
int aMask = dcm.getAlphaMask();
int rMask = dcm.getRedMask();
int gMask = dcm.getGreenMask();
int bMask = dcm.getBlueMask();
if (numBands == 3 &&
aMask == 0 &&
rMask == DCM_RGBX_RED_MASK &&
gMask == DCM_RGBX_GREEN_MASK &&
bMask == DCM_RGBX_BLUE_MASK)
{
sType = SurfaceType.IntRgbx;
} else if (numBands == 4 &&
aMask == DCM_ARGBBM_ALPHA_MASK &&
rMask == DCM_ARGBBM_RED_MASK &&
gMask == DCM_ARGBBM_GREEN_MASK &&
bMask == DCM_ARGBBM_BLUE_MASK)
{
sType = SurfaceType.IntArgbBm;
} else {
sType = SurfaceType.AnyDcm;
}
}
sData = createDataIC(bufImg, sType);
break;
} else if (raster instanceof ShortComponentRaster &&
raster.getNumDataElements() == 1 &&
((ShortComponentRaster)raster).getPixelStride() == 1)
{
SurfaceType sType = SurfaceType.AnyShort;
IndexColorModel icm = null;
if (cm instanceof DirectColorModel) {
DirectColorModel dcm = (DirectColorModel) cm;
int aMask = dcm.getAlphaMask();
int rMask = dcm.getRedMask();