Block[] scaledMCU = new Block[mcu.length];
for (int i = 0; i < scaledMCU.length; i++)
scaledMCU[i] = new Block(hSize, vSize);
int[] preds = new int[sofnSegment.numberOfComponents];
ColorModel colorModel;
WritableRaster raster;
if (sofnSegment.numberOfComponents == 3)
{
colorModel = new DirectColorModel(24,
0x00ff0000, 0x0000ff00, 0x000000ff);
raster = WritableRaster.createPackedRaster(sofnSegment.width, sofnSegment.height,
new int[]{0x00ff0000,0x0000ff00,0x000000ff});
}
else if (sofnSegment.numberOfComponents == 1)
{
colorModel = new DirectColorModel(24,
0x00ff0000, 0x0000ff00, 0x000000ff);
raster = WritableRaster.createPackedRaster(sofnSegment.width, sofnSegment.height,
new int[]{0x00ff0000,0x0000ff00,0x000000ff});
// FIXME: why do images come out too bright with CS_GRAY?
// colorModel = new ComponentColorModel(
// ColorSpace.getInstance(ColorSpace.CS_GRAY), false, true,
// Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
// raster = colorModel.createCompatibleWritableRaster(
// sofnSegment.width, sofnSegment.height);
}
else
throw new ImageReadException(sofnSegment.numberOfComponents +
" components are invalid or unsupported");
int[] dataBuffer = raster.getDataBuffer();
for (int y1 = 0; y1 < vSize*yMCUs; y1 += vSize)
{
for (int x1 = 0; x1 < hSize*xMCUs; x1 += hSize)