Java examples for 2D Graphics:BufferedImage Create
create Ghost Image
//package com.java2s; import java.awt.AlphaComposite; import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import javax.swing.JLabel; public class Main { private static JLabel imgObserver = new JLabel(); public static Image createGhostImage(Image img) { BufferedImage ghost = new BufferedImage(img.getWidth(imgObserver), img.getHeight(imgObserver), BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g2 = ghost.createGraphics(); g2.setComposite(AlphaComposite .getInstance(AlphaComposite.SRC, 0.5f)); g2.drawImage(img, 0, 0, ghost.getWidth(), ghost.getHeight(), imgObserver);/*from w w w .j a v a 2 s . co m*/ g2.dispose(); return ghost; } }