// scales second image to size of first static BufferedImage addBufferedImagesPixelByPixel(BufferedImage img1, BufferedImage img2) { int w = img1.getWidth(), h = img1.getHeight(); BufferedImage img = newImage(w, h); BufferedImage img2scaled = resizeImage(img2, w, h); for y to h: for x to w: setRGB(img, x, y, rgbAdd(bufferedImage_getRGB(img1, x, y), bufferedImage_getRGB(img2scaled, x, y)); ret img; }