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