static IBWImage clipIBWImage(IBWImage img, int x1, int y1, int w, int h) { if (x1 == 0 && y1 == 0 && w == img.getWidth() && h == img.getHeight()) ret img; ret new IBWImage { public int getWidth() { ret w; } public int getHeight() { ret h; } public float getFloatPixel(int x, int y) { ret img.getFloatPixel(x+x1, y+y1); } }; } static IBWImage clipIBWImage(IBWImage img, Rect r) { ret clipIBWImage(img, r.x, r.y, r.w, r.h); }