Java examples for 2D Graphics:BufferedImage Resize
merge Image BufferedImage
//package com.java2s; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.image.BufferedImage; public class Main { public static BufferedImage mergeImage(BufferedImage a, BufferedImage b) { BufferedImage img = new BufferedImage(800, 600, 1); Dimension dim = new Dimension(img.getWidth(), img.getHeight()); Graphics g = img.getGraphics(); for (int r = 0; r < dim.width; r++) { for (int c = 0; c < dim.height; c++) { //System.out.println("row: " + r + " col: " + c); Color ac = new Color(a.getRGB(r, c)); Color bc = new Color(b.getRGB(r, c)); g.setColor(new Color((ac.getRed() + bc.getRed()) / 2, (ac .getGreen() + bc.getGreen()) / 2, (ac.getBlue() + bc.getBlue()) / 2)); g.fillRect(r, c, 1, 1);/*from w w w.j a v a 2 s . c o m*/ } } return img; } }