public BufferedImage getBuffer() { if (img != null) { return img.getSnapshot(); } else { return null; } }
public BufferedImage getBuffer() { return img.getSnapshot(); }
protected BufferedImage toBufferedImage(Image image) { if (image instanceof VolatileImage) { return ((VolatileImage) image).getSnapshot(); } int width = image.getWidth(null); int height = image.getHeight(null); if (width < 0 || height < 0) { return null; } BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); bufferedImage.createGraphics().drawImage(image, null, null); return bufferedImage; }
public static BufferedImage imageToBufferedImage(Image image, int imageType) { if (image instanceof BufferedImage) { return (BufferedImage) image; } else if (image instanceof VolatileImage) { return ((VolatileImage) image).getSnapshot(); } else { loadImage(image); final BufferedImage result = new BufferedImage(image.getWidth(null), image.getHeight(null), imageType); final Graphics2D g2 = result.createGraphics(); g2.drawImage(image, null, null); g2.dispose(); return result; } }
protected WritableRaster getRaster() { WritableRaster raster = null; if (primaryGraphics) { /* // 'offscreen' will probably be removed in the next release if (useOffscreen) { raster = offscreen.getRaster(); } else*/ if (image instanceof VolatileImage) { // when possible, we'll try VolatileImage raster = ((VolatileImage) image).getSnapshot().getRaster(); } } if (raster == null) { raster = ((BufferedImage) image).getRaster(); } // On Raspberry Pi (and perhaps other platforms, the color buffer won't // necessarily be the int array that we'd like. Need to convert it here. // Not that this would probably mean getRaster() would need to work more // like loadRaster/updateRaster because the pixels will need to be // temporarily moved to (and later from) a buffer that's understood by // the rest of the Processing source. // https://github.com/processing/processing/issues/2010 if (raster.getTransferType() != DataBuffer.TYPE_INT) { System.err.println("See https://github.com/processing/processing/issues/2010"); throw new RuntimeException("Pixel operations are not supported on this device."); } return raster; }
return getSnapshot().getSource();