Here you can find the source of makeColorTransparent(BufferedImage image, Color color)
public static BufferedImage makeColorTransparent(BufferedImage image, Color color)
//package com.java2s; //License from project: Apache License import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { public static BufferedImage makeColorTransparent(BufferedImage image, Color color) { BufferedImage dimg = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = dimg.createGraphics(); g.setComposite(AlphaComposite.Src); g.drawImage(image, null, 0, 0);/*from w ww. j a va2 s . co m*/ g.dispose(); for (int i = 0; i < dimg.getHeight(); i++) { for (int j = 0; j < dimg.getWidth(); j++) { if (dimg.getRGB(j, i) == color.getRGB()) { dimg.setRGB(j, i, 0x8F1C1C); } } } return dimg; } }