img = this.getNewImage(img);
int[] pixels = new int[w * h]; BufferedImage out = (BufferedImage) this.createImage(w, h); PixelGrabber pg = new PixelGrabber(img.getSubimage(x, y, w, h), 0, 0, w, h, pixels, 0, w); try { pg.grabPixels(); } catch (InterruptedException e) { System.err.println("interrupted waiting for pixels!"); return null; } Graphics g = out.getGraphics(); int alpha, blue, red, green; Color c; for (int j = 0; j < h; j++) { for (int i = 0; i < w; i++) { alpha = (pixels[j * w + i] >> 24) & 0xff; red = (pixels[j * w + i] >> 16) & 0xff; green = (pixels[j * w + i] >> 8) & 0xff; blue = (pixels[j * w + i]) & 0xff;  c = new Color(red, green, blue, alpha); g.setColor(c); g.drawLine(i, j, i, j); } } return out;
    protected void getNewImage()    {        img = this.getNewImage(img);    }