{
harness.checkPoint("two colorspaces defined, " + cspace1 + ", " + cspace2);
ColorSpace cs = ColorSpace.getInstance(cspace1);
ColorSpace cs2 = ColorSpace.getInstance(cspace2);
ColorConvertOp op = new ColorConvertOp(cs, cs2, null);
int bands = cs2.getNumComponents();
Raster src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, bands, new Point(5, 5));
try
{
Raster dst = op.createCompatibleDestRaster(src);
harness.check(dst.getHeight(), src.getHeight());
harness.check(dst.getWidth(), src.getWidth());
harness.check(dst.getNumBands(), bands);
harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
harness.check(dst.getNumDataElements(), cs2.getNumComponents());
harness.check(dst.getSampleModel() instanceof PixelInterleavedSampleModel);
harness.check(dst.getDataBuffer() instanceof DataBufferByte);
PixelInterleavedSampleModel sm = (PixelInterleavedSampleModel)dst.getSampleModel();
harness.check(sm.getPixelStride(), cs2.getNumComponents());
harness.check(sm.getScanlineStride(), cs2.getNumComponents() * src.getWidth());
int[] expected = new int[cs2.getNumComponents()];
for (int i = 0; i < expected.length; i++)
expected[i] = i;
harness.check(Arrays.equals(sm.getBandOffsets(), expected));
harness.check(dst.getDataBuffer().getNumBanks(), 1);
harness.check(dst.getDataBuffer().getOffset(), 0);
harness.check(dst.getDataBuffer().getSize(), src.getHeight() * src.getWidth() * cs2.getNumComponents());
}
catch (IllegalArgumentException e)
{
harness.check(false);
}
// Try a different type
src = Raster.createBandedRaster(DataBuffer.TYPE_USHORT, 25, 40, bands, new Point(5, 5));
try
{
Raster dst = op.createCompatibleDestRaster(src);
harness.check(dst.getNumBands(), bands);
harness.check(dst.getTransferType(), DataBuffer.TYPE_BYTE);
harness.check(dst.getDataBuffer().getDataType(), DataBuffer.TYPE_BYTE);
harness.check(dst.getNumDataElements(), cs2.getNumComponents());
harness.check(dst.getSampleModel() instanceof PixelInterleavedSampleModel);
harness.check(dst.getDataBuffer() instanceof DataBufferByte);
}
catch (IllegalArgumentException e)
{
harness.check(false);
}
// Try different number of bands in the source; the destination should
// ignore this and always have ColorSpace.getNumComponents() bands
for (int i = 1; i < bands + 5; i++)
{
src = Raster.createBandedRaster(DataBuffer.TYPE_INT, 25, 40, i, new Point(5, 5));
try
{
Raster dst = op.createCompatibleDestRaster(src);
harness.check(dst.getNumBands(), cs2.getNumComponents());
harness.check(dst.getNumDataElements(), cs2.getNumComponents());
}
catch (IllegalArgumentException e)
{