if (w < 0) { x -= (w = -w); } if (h < 0) { y -= (h = -h); }   x += win.dx; y += win.dy;   if (x < 0) { w += x; x = 0; } if (y < 0) { w += y; y = 0; } if (w > im.getWidth(null)) { w = im.getWidth(null); } if (h > im.getHeight(null)) { h = im.getHeight(null); } if (w <= 0 || h <= 0) { return null;  }   final int[] data = new int[w * h]; PixelGrabber pg = new PixelGrabber(im, x, y, w, h, data, 0, w);
final int[] data = new int[r.width * r.height]; PixelGrabber pg = new PixelGrabber(im, r.x, r.y, r.width, r.height, data, 0, r.width);
public static int[] Grab(vWindow win, int x, int y, int w, int h) {    Image im = win.getCanvas().i;    // adjust negative width and height    if (w < 0) {	x -= (w = -w);    }    if (h < 0) {	y -= (h = -h);    }    // factor in dx/dy    x += win.dx;    y += win.dy;    // trim to image bounds	//#%#% should gen bg color instead??    if (x < 0) {	w += x;	x = 0;    }    if (y < 0) {	w += y;	y = 0;    }    if (w > im.getWidth(null)) {	w = im.getWidth(null);    }    if (h > im.getHeight(null)) {	h = im.getHeight(null);    }    if (w <= 0 || h <= 0) {	return null; /*FAIL*/    }    // get data    final int[] data = new int[w * h];    PixelGrabber pg = new PixelGrabber(im, x, y, w, h, data, 0, w);    try {	pg.grabPixels();	return data;    } catch (InterruptedException e) {	return null; /*FAIL*/    }}