Package java.awt.image

Examples of java.awt.image.AffineTransformOp


  private void testIdentity(TestHarness harness)
  {
    harness.checkPoint("testIdentity");

    AffineTransform xform = new AffineTransform();
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 30, 40));
  }
View Full Code Here


  private void testRotation(TestHarness harness)
  {
    harness.checkPoint("testRotation");

    AffineTransform xform = AffineTransform.getRotateInstance(Math.PI / 2);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(-40, 0, 40, 30));

    // Do it again, but result in a diamond (not another level rectangle)
    xform.rotate(Math.PI / 3);
    op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(-45.980762f,
                                                             -34.641018f,
                                                             45.980762f,
                                                             49.641018f));
   
    // Rotation about a point
    xform.setToIdentity();
    xform.rotate(Math.PI / 2, 10, 15);
    op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(-15, 5, 40, 30));
  }
View Full Code Here

  {
    harness.checkPoint("testScale");
   
    AffineTransform xform = AffineTransform.getScaleInstance(1.0, 1.0);
    BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 30, 40));
   
    xform.scale(2.5, 4.75);
    op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 75, 190));  
  }
View Full Code Here

  {
    harness.checkPoint("testHarness");
   
    AffineTransform xform = AffineTransform.getShearInstance(1.5, 3.25);
    BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(0, 0, 90, 137.5f));
  }
View Full Code Here

  {
    harness.checkPoint("testTranslation");

    AffineTransform xform = AffineTransform.getTranslateInstance(75, 50);
    BufferedImage img = new BufferedImage(30, 40, BufferedImage.TYPE_INT_RGB);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getBounds2D(img), new Rectangle2D.Float(75, 50, 30, 40));
  }
View Full Code Here

    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());
  }
View Full Code Here

  private void testIdentity(TestHarness harness)
  {
    harness.checkPoint("testIdentity");

    AffineTransform xform = new AffineTransform();
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(5,5));
   
    Point2D pt = null;
    Point2D pt2 = op.getPoint2D(new Point2D.Double(10,-5), pt);
    harness.check(pt, null);        // this is what the ref impl does...
    harness.check(pt2, new Point2D.Double(10, -5));
   
    pt = new Point2D.Double(0,0);
    pt2 = op.getPoint2D(new Point2D.Double(10,-5), pt);
    harness.check(pt, new Point2D.Double(10, -5));
    harness.check(pt, pt2);
   
    pt = new Point2D.Float(0,0);
    op.getPoint2D(new Point2D.Float(-10,-5), pt);
    harness.check(pt, new Point2D.Float(-10, -5));
  }
View Full Code Here

  private void testRotation(TestHarness harness)
  {
    harness.checkPoint("testRotation");

    AffineTransform xform = AffineTransform.getRotateInstance(Math.PI / 2);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(-5,5));

    // Do it again, but result in a diamond (not another level rectangle)
    xform.rotate(Math.PI / 3);
    op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(-6.830127018922193, -1.8301270189221923));
   
    // Rotation about a point
    xform.setToIdentity();
    xform.rotate(Math.PI / 2, 10, 2);
    op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(7,-3));
  }
View Full Code Here

  private void testScale(TestHarness harness)
  {
    harness.checkPoint("testScale");
   
    AffineTransform xform = AffineTransform.getScaleInstance(1.0, 1.0);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(5, 5));
   
    xform.scale(2.5, 4.75);
    op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(12.5,23.75));
  }
View Full Code Here

  private void testShear(TestHarness harness)
  {
    harness.checkPoint("testShear");
   
    AffineTransform xform = AffineTransform.getShearInstance(1.5, 3.25);
    AffineTransformOp op = new AffineTransformOp(xform, AffineTransformOp.TYPE_BICUBIC);
    harness.check(op.getPoint2D(new Point2D.Double(5, 5), null), new Point2D.Double(12.5,21.25));
  }
View Full Code Here

TOP

Related Classes of java.awt.image.AffineTransformOp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.