@Test(dataProvider="profileNames") public void must_create_a_valid_Granger_rainbow (final @Nonnull String profileName) throws Exception { final EditableImage image = fixture.createGrangerRainbow(1024, 768, profileName); image.execute2(new ConvertToBufferedImageOp()).execute(new WriteOp("TIFF", "/tmp/grangersynth " + profileName + ".tif")); // FIXME: assertion }
@Override protected PlanarImage execute (WriteOp operation, final EditableImage image, PlanarImage planarImage) { Object output = operation.getOutput(); if (!(output instanceof File)) { throw new UnsupportedOperationException("only File outputs are supported"); } // FIXME: should be using Image I/O instead of JAI File file = (File)output; ParameterBlock pb = new ParameterBlock(); pb.addSource(planarImage); pb.add(file.getAbsolutePath()); // FIXME: file format? JAI.create("filestore", pb); JAIUtils.logImage(log, ">>>> WriteJAIOp returning", planarImage); return planarImage; } }
@Test public void testExecute() throws IOException { // ImplementationFactoryJ2D.unregister(SizeOp.class); Lookup.getDefault().lookup(ImplementationFactoryJAI.class); final EditableImage image = EditableImage.create(new ReadOp(file_20030701_0043_jpg)); for (float scale = 0.1f; scale <= 1.0f; scale += 0.1f) { final EditableImage result = image.execute2(new SizeOp(scale)); result.execute(new ForceRenderingOp()); result.execute(new WriteOp("JPEG", "build/test/results/result-" + scale + ".jpg")); } } }
private void runTest (EditableImage image, double angle, String checksum, int width, int height) { if (image != null) { EditableImage result = image.execute2(new RotateOp(angle)); String suffix = image.getInnerProperty(SampleModel.class).getClass().getName(); File f = (File)result.execute(new WriteOp("TIFF", tmp + "/" + angle + suffix + ".tif")).getOutput(); assertChecksum(checksum, f); AssertJUnit.assertEquals(width, result.getWidth()); AssertJUnit.assertEquals(height, result.getHeight()); } } }
private void runTest (EditableImage image, double scale, String checksum, int width, int height) { if (image != null) { String suffix = image.getInnerProperty(SampleModel.class).getClass().getName(); EditableImage result = image.execute2(new ScaleOp(scale)); File f = (File)result.execute(new WriteOp("TIFF", tmp + "/" + scale + suffix + ".tif")).getOutput(); assertChecksum(checksum, f); AssertJUnit.assertEquals(width, result.getWidth()); AssertJUnit.assertEquals(height, result.getHeight()); } } }
@Test public void testRotate (final EditableImage image, final int angle, final String prefix, final String hash) { EditableImage result = image.execute2(new RotateQuadrantOp(angle)); File f = (File)result.execute(new WriteOp("TIFF", tmp + "/" + prefix + "-" + angle + ".tif")).getOutput(); assertChecksum(hash, f); if ((angle / 90) % 2 == 0) { AssertJUnit.assertEquals(image.getWidth(), result.getWidth()); AssertJUnit.assertEquals(image.getHeight(), result.getHeight()); } else { AssertJUnit.assertEquals(image.getWidth(), result.getHeight()); AssertJUnit.assertEquals(image.getHeight(), result.getWidth()); } } }