コード例 #1
0
  private static void testConvertData(
      AffineTransformationStep transformer,
      TransformationStepInput input,
      ImagePointTransformer expectedPointTransformer) {

    TransformedImage transformedImage =
        transformer.render(Cancellation.UNCANCELABLE_TOKEN, input, null);

    assertEquals(input.getDestinationWidth(), transformedImage.getImage().getWidth());
    assertEquals(input.getDestinationHeight(), transformedImage.getImage().getHeight());

    ImagePointTransformer actualPointTransformer = transformedImage.getPointTransformer();
    PointTransformerChecks.checkEqualPointTransformers(
        expectedPointTransformer, actualPointTransformer);
  }
コード例 #2
0
  @Test
  public void testProperties2() {
    Color bckgColor = new Color(1, 2, 3, 4);
    BasicImageTransformations affine = BasicImageTransformations.newRotateTransformation(3.0);
    AffineTransform expectedAffine = AffineTransformationStep.getTransformationMatrix(affine);
    for (InterpolationType interpolation : InterpolationType.values()) {
      AffineTransformationStep transf =
          new AffineTransformationStep(affine, bckgColor, interpolation);

      assertSame(bckgColor, transf.getBackgroundColor());
      assertSame(interpolation, transf.getInterpolationType());
      PointTransformerChecks.checkEqualPointTransformers(
          new AffineImagePointTransformer(expectedAffine),
          new AffineImagePointTransformer(transf.getTransformations()));
    }
  }
コード例 #3
0
  @Test
  public void testProperties1() {
    Color bckgColor = new Color(1, 2, 3, 4);
    AffineTransform expectedAffine = nonIdentityAffineTransform();
    for (InterpolationType interpolation : InterpolationType.values()) {
      AffineTransform affine = new AffineTransform(expectedAffine);
      AffineTransformationStep transf =
          new AffineTransformationStep(affine, bckgColor, interpolation);

      assertSame(bckgColor, transf.getBackgroundColor());
      assertSame(interpolation, transf.getInterpolationType());
      PointTransformerChecks.checkEqualPointTransformers(
          new AffineImagePointTransformer(expectedAffine),
          new AffineImagePointTransformer(transf.getTransformations()));
    }
  }
コード例 #4
0
  @Test
  public void testRenderNullInputProperties() {
    for (InterpolationType interpolation : InterpolationType.values()) {
      AffineTransformationStep transformer =
          new AffineTransformationStep(
              BasicImageTransformations.newZoomTransformation(100.0, 100.0),
              Color.GRAY,
              interpolation);

      TransformationStepInput input =
          new TransformationStepInput(null, 100, 100, TransformedImage.NULL_IMAGE);
      TransformedImage result = transformer.render(Cancellation.UNCANCELABLE_TOKEN, input, null);

      assertNull(result.getImage());
      PointTransformerChecks.checkEqualPointTransformers(
          AffineImagePointTransformer.IDENTITY, result.getPointTransformer());
    }
  }
コード例 #5
0
  public void testRenderNotUsingOffered(BufferedImage offered, int width, int height, int type) {
    for (InterpolationType interpolation : InterpolationType.values()) {
      AffineTransformationStep transformer =
          new AffineTransformationStep(
              BasicImageTransformations.identityTransformation(), Color.GRAY, interpolation);

      TransformedImage inputImage = blankTransformedImage(Color.BLUE, width, height, type);

      TransformationStepInput input = new TransformationStepInput(null, width, height, inputImage);
      TransformedImage result = transformer.render(Cancellation.UNCANCELABLE_TOKEN, input, offered);
      assertNotSame(offered, result.getImage());

      ImageTestUtils.checkBlankImage(result.getImage(), Color.BLUE);

      PointTransformerChecks.checkEqualPointTransformers(
          AffineImagePointTransformer.IDENTITY, result.getPointTransformer());
    }
  }