@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())); } }
@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())); } }
@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()); } }
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()); } }
@Test public void testRender() { BasicImageTransformations.Builder builder = new BasicImageTransformations.Builder(); builder.setFlipHorizontal(true); builder.setFlipVertical(true); builder.setOffset(5.0, 6.0); builder.setRotateInRadians(Math.PI / 6.0); builder.setZoomX(3.0); builder.setZoomY(4.0); BasicImageTransformations transf = builder.create(); for (InterpolationType interpolation : InterpolationType.values()) { AffineTransform affinTransf = AffineTransformationStep.getTransformationMatrix(transf); AffineTransformationStep transformer1 = new AffineTransformationStep(transf, Color.GRAY, interpolation); AffineTransformationStep transformer2 = new AffineTransformationStep(affinTransf, Color.GRAY, interpolation); // Test that it does not affect transformer2 affinTransf.translate(1000.0, 1000.0); int srcWidth = 20; int srcHeight = 30; int destWidth = 110; int destHeight = 120; BufferedImage srcImage = new BufferedImage(srcWidth, srcHeight, BufferedImage.TYPE_BYTE_GRAY); TransformedImage inputImage = new TransformedImage(srcImage, null); TransformationStepInput input = new TransformationStepInput(null, destWidth, destHeight, inputImage); AffineTransform expectedTransf = AffineTransformationStep.getTransformationMatrix( transf, srcWidth, srcHeight, destWidth, destHeight); ImagePointTransformer expectedPointTransf = new AffineImagePointTransformer(expectedTransf); testConvertData(transformer1, input, expectedPointTransf); testConvertData(transformer2, input, expectedPointTransf); assertNotNull(transformer1.toString()); assertNotNull(transformer2.toString()); } }