01: package org.geotools.arcsde.gce;
02:
03: import java.awt.Image;
04: import java.awt.image.BufferedImage;
05: import java.awt.image.RenderedImage;
06: import java.io.IOException;
07: import java.io.InputStream;
08:
09: import javax.imageio.ImageIO;
10: import javax.media.jai.PlanarImage;
11:
12: public class RasterTestUtils {
13:
14: public static boolean imageEquals(RenderedImage image,
15: String filename) throws IOException {
16: BufferedImage original = PlanarImage.wrapRenderedImage(image)
17: .getAsBufferedImage();
18: InputStream in = org.geotools.test.TestData.url(null,
19: "raster-images/" + filename).openStream();
20: BufferedImage expected = ImageIO.read(in);
21:
22: for (int xpos = 0; xpos < expected.getWidth(); xpos++) {
23: for (int ypos = 0; ypos < expected.getHeight(); ypos++) {
24: if (original.getRGB(xpos, ypos) != expected.getRGB(
25: xpos, ypos))
26: return false;
27: }
28: }
29: return true;
30: }
31:
32: }
|