public int get(int x, int y) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) return 0; // return ((BufferedImage) image).getRGB(x, y); WritableRaster raster = ((BufferedImage) (primarySurface ? offscreen : image)).getRaster(); raster.getDataElements(x, y, getset); return getset[0]; }
public void loadPixels() { if ((pixels == null) || (pixels.length != width * height)) { pixels = new int[width * height]; } // ((BufferedImage) image).getRGB(0, 0, width, height, pixels, 0, width); WritableRaster raster = ((BufferedImage) (primarySurface ? offscreen : image)).getRaster(); raster.getDataElements(0, 0, width, height, pixels); }
public PImage getImpl(int x, int y, int w, int h) { PImage output = new PImage(w, h); output.parent = parent; // oops, the last parameter is the scan size of the *target* buffer // ((BufferedImage) image).getRGB(x, y, w, h, output.pixels, 0, w); WritableRaster raster = ((BufferedImage) (primarySurface ? offscreen : image)).getRaster(); raster.getDataElements(x, y, w, h, output.pixels); return output; }