static void copyRGBImage(RGBImage src, int srcX, int srcY, RGBImage dst, int dstX, int dstY) { copyRGBImage(src, srcX, srcY, dst, dstX, dstY, src.getWidth()-srcX, src.getHeight()-srcY); } static void copyRGBImage(RGBImage src, int srcX, int srcY, RGBImage dst, int dstX, int dstY, int w, int h) { w = min(w, dst.getWidth()-dstX); h = min(h, dst.getHeight()-dstY); w = min(w, src.getWidth()-srcX); h = min(h, src.getHeight()-srcY); for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) dst.setPixel(dstX+x, dstY+y, src.getInt(srcX+x, srcY+y)); }