docs: public static Rectangle getSelectedBounds(BufferedImage p) {
  		int width = p.getWidth();
          int height = p.getHeight();
  		int maxX = 0, maxY = 0, minX = width, minY = height;
  		boolean anySelected = false;
  		int y1;
  		int [] pixels = null;
  		
  		for (y1 = height-1; y1 >= 0; y1--) {
  			pixels = getRGB( p, 0, y1, width, 1, pixels );
  			for (int x = 0; x < minX; x++) {
  				if ((pixels[x] & 0xff000000) != 0) {
  					minX = x;
  					maxY = y1;
  					anySelected = true;
  					break;
  				}
  			}
  			for (int x = width-1; x >= maxX; x--) {
  				if ((pixels[x] & 0xff000000) != 0) {
  					maxX = x;
  					maxY = y1;
  					anySelected = true;
  					break;
  				}
  			}
  			if ( anySelected )
  				break;
  		}
  		pixels = null;
  		for (int y = 0; y < y1; y++) {
  			pixels = getRGB( p, 0, y, width, 1, pixels );
  			for (int x = 0; x < minX; x++) {
  				if ((pixels[x] & 0xff000000) != 0) {
  					minX = x;
  					if ( y < minY )
  						minY = y;
  					anySelected = true;
  					break;
  				}
  			}
  			for (int x = width-1; x >= maxX; x--) {
  				if ((pixels[x] & 0xff000000) != 0) {
  					maxX = x;
  					if ( y < minY )
  						minY = y;
  					anySelected = true;
  					break;
  				}
  			}
  		}
  		if ( anySelected )
  			return new Rectangle( minX, minY, maxX-minX+1, maxY-minY+1 );
  		return null;
  	}