BufferedImage img = new BufferedImage(20, 20, BufferedImage.TYPE_USHORT_GRAY);
Graphics2D g = (Graphics2D)img.getGraphics();
g.draw(new Line2D.Double(0, 0, 20, 20));
AffineTransform xform = new AffineTransform();
AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
// Src and dst images cannot be the same
try
{
op.filter(img, img);
harness.check(false);
}
catch (IllegalArgumentException e)
{
harness.check(true);
}
// Src and dst are different sizes (allowed)
BufferedImage dst = new BufferedImage(30, 40, BufferedImage.TYPE_USHORT_GRAY);
try
{
op.filter(img, dst);
harness.check(true);
}
catch (IllegalArgumentException e)
{
harness.check(false);
}
// Src and dst have different tpyes (allowed)
dst = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
try
{
op.filter(img, dst);
harness.check(true);
}
catch (IllegalArgumentException e)
{
harness.check(false);
}
// Src and dst are different sizes AND different types (not allowed)
/*
* Fails on the ref impl...
*
dst = new BufferedImage(30, 40, BufferedImage.TYPE_INT_ARGB);
try
{
op.filter(img, dst);
harness.check(false);
}
catch (IllegalArgumentException e)
{
harness.check(true);
}
*/
// Checks the destination image type
dst = op.filter(img, null);
harness.check(dst.getType(), op.createCompatibleDestImage(img, null).getType());
}