BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
Graphics2D g = (Graphics2D)img.getGraphics();
g.draw(new Line2D.Double(0, 0, 20, 20));
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorConvertOp op = new ColorConvertOp(cs, null);
// Check null destination
try
{
BufferedImage dst = op.filter(img, null);
harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
// Any other checks to run? Show the data was filtered properly?
}
catch (IllegalArgumentException e)
{
harness.check(false);
}
// Check non-null destination
try
{
BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB);
dst = op.filter(img, dst);
harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
// Any other checks to run?
}
catch (IllegalArgumentException e)
{
harness.check(false);
}
// Can we introduce an alpha?
try
{
BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
dst = op.filter(img, dst);
harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_RGB);
// Any other checks to run?
}
catch (IllegalArgumentException e)
{
harness.check(false);
}
// Different destination type: this should end up as GRAY, via RGB
// (but how can I test the intermediate step?)
try
{
BufferedImage dst = new BufferedImage(20, 20, BufferedImage.TYPE_BYTE_GRAY);
dst = op.filter(img, dst);
harness.check(dst.getColorModel().getColorSpace().getType(), ColorSpace.TYPE_GRAY);
// Any other checks to run?
}
catch (IllegalArgumentException e)
{