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;
  }