logger.log(Level.SEVERE, "grabber error" + e); if ((grabber.status() & ImageObserver.ABORT) != 0) logger.info("grabber error");
logger.log(Level.SEVERE, "grabber error" + e); if ((topoGrabber.status() & ImageObserver.ABORT) != 0) logger.info("grabber error");
public ImageFunction2D(Image image, int edgeAction, boolean alpha) { PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, null, 0, -1); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("interrupted waiting for pixels!"); } if ((pg.status() & ImageObserver.ABORT) != 0) { throw new RuntimeException("image fetch aborted"); } init((int[])pg.getPixels(), pg.getWidth(), pg.getHeight(), edgeAction, alpha); }
/** * Cretae a BufferedImage from an ImageProducer. * @param producer the ImageProducer * @return a new TYPE_INT_ARGB BufferedImage */ public static BufferedImage createImage(ImageProducer producer) { PixelGrabber pg = new PixelGrabber(producer, 0, 0, -1, -1, null, 0, 0); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("Image fetch interrupted"); } if ((pg.status() & ImageObserver.ABORT) != 0) throw new RuntimeException("Image fetch aborted"); if ((pg.status() & ImageObserver.ERROR) != 0) throw new RuntimeException("Image fetch error"); BufferedImage p = new BufferedImage(pg.getWidth(), pg.getHeight(), BufferedImage.TYPE_INT_ARGB); p.setRGB(0, 0, pg.getWidth(), pg.getHeight(), (int[])pg.getPixels(), 0, pg.getWidth()); return p; }
/** * Cretae a BufferedImage from an ImageProducer. * @param producer the ImageProducer * @return a new TYPE_INT_ARGB BufferedImage */ public static BufferedImage createImage(ImageProducer producer) { PixelGrabber pg = new PixelGrabber(producer, 0, 0, -1, -1, null, 0, 0); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("Image fetch interrupted"); } if ((pg.status() & ImageObserver.ABORT) != 0) throw new RuntimeException("Image fetch aborted"); if ((pg.status() & ImageObserver.ERROR) != 0) throw new RuntimeException("Image fetch error"); BufferedImage p = new BufferedImage(pg.getWidth(), pg.getHeight(), BufferedImage.TYPE_INT_ARGB); p.setRGB(0, 0, pg.getWidth(), pg.getHeight(), (int[])pg.getPixels(), 0, pg.getWidth()); return p; }
/** * Cretae a BufferedImage from an ImageProducer. * @param producer the ImageProducer * @return a new TYPE_INT_ARGB BufferedImage */ public static BufferedImage createImage(ImageProducer producer) { PixelGrabber pg = new PixelGrabber(producer, 0, 0, -1, -1, null, 0, 0); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("Image fetch interrupted"); } if ((pg.status() & ImageObserver.ABORT) != 0) throw new RuntimeException("Image fetch aborted"); if ((pg.status() & ImageObserver.ERROR) != 0) throw new RuntimeException("Image fetch error"); BufferedImage p = new BufferedImage(pg.getWidth(), pg.getHeight(), BufferedImage.TYPE_INT_ARGB); p.setRGB(0, 0, pg.getWidth(), pg.getHeight(), (int[])pg.getPixels(), 0, pg.getWidth()); return p; }
public ImageProducer filter(Image image1, Image image2, int x, int y, int w, int h) { int[] pixels1 = new int[w * h]; int[] pixels2 = new int[w * h]; int[] pixels3 = new int[w * h]; PixelGrabber pg1 = new PixelGrabber(image1, x, y, w, h, pixels1, 0, w); PixelGrabber pg2 = new PixelGrabber(image2, x, y, w, h, pixels2, 0, w); try { pg1.grabPixels(); pg2.grabPixels(); } catch (InterruptedException e) { System.err.println("interrupted waiting for pixels!"); return null; } if ((pg1.status() & ImageObserver.ABORT) != 0) { System.err.println("image fetch aborted or errored"); return null; } if ((pg2.status() & ImageObserver.ABORT) != 0) { System.err.println("image fetch aborted or errored"); return null; } for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { int k = j * w + i; pixels3[k] = filterRGB(x+i, y+j, pixels1[k], pixels2[k]); } } return new MemoryImageSource(w, h, pixels3, 0, w); }
public ImageFunction2D(Image image, int edgeAction, boolean alpha) { PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, null, 0, -1); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("interrupted waiting for pixels!"); } if ((pg.status() & ImageObserver.ABORT) != 0) { throw new RuntimeException("image fetch aborted"); } init((int[])pg.getPixels(), pg.getWidth(), pg.getHeight(), edgeAction, alpha); }
public ImageProducer filter(Image image1, Image image2, int x, int y, int w, int h) { int[] pixels1 = new int[w * h]; int[] pixels2 = new int[w * h]; int[] pixels3 = new int[w * h]; PixelGrabber pg1 = new PixelGrabber(image1, x, y, w, h, pixels1, 0, w); PixelGrabber pg2 = new PixelGrabber(image2, x, y, w, h, pixels2, 0, w); try { pg1.grabPixels(); pg2.grabPixels(); } catch (InterruptedException e) { System.err.println("interrupted waiting for pixels!"); return null; } if ((pg1.status() & ImageObserver.ABORT) != 0) { System.err.println("image fetch aborted or errored"); return null; } if ((pg2.status() & ImageObserver.ABORT) != 0) { System.err.println("image fetch aborted or errored"); return null; } for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { int k = j * w + i; pixels3[k] = filterRGB(x+i, y+j, pixels1[k], pixels2[k]); } } return new MemoryImageSource(w, h, pixels3, 0, w); }
public ImageFunction2D(Image image, int edgeAction, boolean alpha) { PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, null, 0, -1); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("interrupted waiting for pixels!"); } if ((pg.status() & ImageObserver.ABORT) != 0) { throw new RuntimeException("image fetch aborted"); } init((int[])pg.getPixels(), pg.getWidth(), pg.getHeight(), edgeAction, alpha); }
public ImageProducer filter(Image image1, Image image2, int x, int y, int w, int h) { int[] pixels1 = new int[w * h]; int[] pixels2 = new int[w * h]; int[] pixels3 = new int[w * h]; PixelGrabber pg1 = new PixelGrabber(image1, x, y, w, h, pixels1, 0, w); PixelGrabber pg2 = new PixelGrabber(image2, x, y, w, h, pixels2, 0, w); try { pg1.grabPixels(); pg2.grabPixels(); } catch (InterruptedException e) { System.err.println("interrupted waiting for pixels!"); return null; } if ((pg1.status() & ImageObserver.ABORT) != 0) { System.err.println("image fetch aborted or errored"); return null; } if ((pg2.status() & ImageObserver.ABORT) != 0) { System.err.println("image fetch aborted or errored"); return null; } for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { int k = j * w + i; pixels3[k] = filterRGB(x+i, y+j, pixels1[k], pixels2[k]); } } return new MemoryImageSource(w, h, pixels3, 0, w); }
protected int[][] grabPixels(final Image image) { final int width = image.getWidth(null); final int lines = image.getHeight(null); final int pixels[] = new int[width * lines]; final PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, lines, pixels, 0, width); grabber.setColorModel(ColorModel.getRGBdefault()); try { if (grabber.grabPixels() && (grabber.status() & ImageObserver.ALLBITS) != 0) { final int[][] array = new int[lines][width]; int srcPos = 0; for (int line = 0; line < lines; line++) { array[line] = new int[width]; System.arraycopy(pixels, srcPos, array[line], 0, width); for (int pixel = 0; pixel < array[line].length; pixel++) { array[line][pixel] = array[line][pixel] | 0xFF000000; } srcPos += width; } return array; } // TODO what happens if the grab fails? return new int[lines][width]; } catch (final InterruptedException e) { throw new IsisException(e); } }
public ImageFunction2D(Image image, int edgeAction, boolean alpha) { PixelGrabber pg = new PixelGrabber(image, 0, 0, -1, -1, null, 0, -1); try { pg.grabPixels(); } catch (InterruptedException e) { throw new RuntimeException("interrupted waiting for pixels!"); } if ((pg.status() & ImageObserver.ABORT) != 0) { throw new RuntimeException("image fetch aborted"); } init((int[])pg.getPixels(), pg.getWidth(), pg.getHeight(), edgeAction, alpha); }
protected int[][] grabPixels(final Image image) { final int width = image.getWidth(null); final int lines = image.getHeight(null); final int pixels[] = new int[width * lines]; final PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, lines, pixels, 0, width); grabber.setColorModel(ColorModel.getRGBdefault()); try { if (grabber.grabPixels() && (grabber.status() & ImageObserver.ALLBITS) != 0) { final int[][] array = new int[lines][width]; int srcPos = 0; for (int line = 0; line < lines; line++) { array[line] = new int[width]; System.arraycopy(pixels, srcPos, array[line], 0, width); for (int pixel = 0; pixel < array[line].length; pixel++ ) { array[line][pixel] =array[line][pixel] | 0xFF000000; } srcPos += width; } return array; } // TODO what happens if the grab fails? return new int[lines][width]; } catch (final InterruptedException e) { throw new NakedObjectException(e); } }
protected int[][] grabPixels(final Image image) { final int width = image.getWidth(null); final int lines = image.getHeight(null); final int pixels[] = new int[width * lines]; final PixelGrabber grabber = new PixelGrabber(image, 0, 0, width, lines, pixels, 0, width); grabber.setColorModel(ColorModel.getRGBdefault()); try { if (grabber.grabPixels() && (grabber.status() & ImageObserver.ALLBITS) != 0) { final int[][] array = new int[lines][width]; int srcPos = 0; for (int line = 0; line < lines; line++) { array[line] = new int[width]; System.arraycopy(pixels, srcPos, array[line], 0, width); for (int pixel = 0; pixel < array[line].length; pixel++ ) { array[line][pixel] =array[line][pixel] | 0xFF000000; } srcPos += width; } return array; } // TODO what happens if the grab fails? return new int[lines][width]; } catch (final InterruptedException e) { throw new NakedObjectException(e); } }
throw new AWTException("Grabber returned false: " + grabber.status());
try { if (grabber.grabPixels() != true) throw new IOException("Grabber false: " + grabber.status()); } catch (InterruptedException e) { System.out.println("Grabber interrupted by anohter thread!\n");
if (grabber.grabPixels() != true) { throw new IOException("Grabber returned false: " + grabber.status());