static BufferedImage blendBufferedImages(BufferedImage bi1, BufferedImage bi2) { ret blendBufferedImages(bi1, bi2, 0.5); } static BufferedImage blendBufferedImages(BufferedImage bi1, BufferedImage bi2, double weight2) { double weight = 1-weight2; int width = bi1.getWidth (); if (width != bi2.getWidth ()) fail("widths not equal"); int height = bi1.getHeight (); if (height != bi2.getHeight ()) fail("heights not equal"); BufferedImage bi3 = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB); int [] rgbim1 = new int [width]; int [] rgbim2 = new int [width]; int [] rgbim3 = new int [width]; for (int row = 0; row < height; row++) { bi1.getRGB (0, row, width, 1, rgbim1, 0, width); bi2.getRGB (0, row, width, 1, rgbim2, 0, width); for (int col = 0; col < width; col++) { int rgb1 = rgbim1 [col]; int r1 = (rgb1 >> 16) & 255; int g1 = (rgb1 >> 8) & 255; int b1 = rgb1 & 255; int rgb2 = rgbim2 [col]; int r2 = (rgb2 >> 16) & 255; int g2 = (rgb2 >> 8) & 255; int b2 = rgb2 & 255; int r3 = (int) (r1*weight+r2*(1.0-weight)); int g3 = (int) (g1*weight+g2*(1.0-weight)); int b3 = (int) (b1*weight+b2*(1.0-weight)); rgbim3 [col] = (r3 << 16) | (g3 << 8) | b3; } bi3.setRGB (0, row, width, 1, rgbim3, 0, width); } return bi3; }