Beispiel #1
0
 /**
  * Make a BufferedImage from the contents of an image file.
  *
  * @param imageFileContents byte array containing the guts of a JPG, GIF, or PNG
  */
 public BufferedImage makeBufferedImage(byte[] imageFileContents) {
   BufferedImage bi = null;
   try {
     InputStream in = new ByteArrayInputStream(imageFileContents);
     bi = javax.imageio.ImageIO.read(in);
   } catch (IOException ioe) {
     GLApp.err("GLImage.makeBufferedImage(): " + ioe);
   }
   return bi;
 }
Beispiel #2
0
 public static void main(String[] args) throws Exception {
   Convolution[] filters = {
     box, new Hanning(1), new Hanning(2), new Hamming(1), new Lanczos(2), new Lanczos(3),
   };
   // BufferedImage in = Resource.loadimg("gfx/invobjs/herbs/crowberry");
   BufferedImage in = javax.imageio.ImageIO.read(new java.io.File("/tmp/e.jpg"));
   Coord tsz = new Coord(300, 300);
   for (int i = 0; i < filters.length; i++) {
     long start = System.nanoTime();
     BufferedImage out = convolvedown(in, tsz, filters[i]);
     System.err.println(System.nanoTime() - start);
     javax.imageio.ImageIO.write(out, "PNG", new java.io.File("/tmp/barda" + i + ".png"));
   }
 }
 public static Image readImage(String filePath) throws IOException {
   return javax.imageio.ImageIO.read(new File(filePath));
 }