Here you can find the source of recolor(BufferedImage src, Color sc)
public static BufferedImage recolor(BufferedImage src, Color sc)
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.image.*; public class Main { public static BufferedImage recolor(BufferedImage src, Color sc) { float[][] colorMatrix = { { ((float) sc.getRed()) / 255f, 0, 0, 0 }, { ((float) sc.getGreen()) / 255f, 0, 0, 0 }, { ((float) sc.getBlue()) / 255f, 0, 0, 0 }, { 0f, 0f, 0f, 1f } };// w w w . ja v a2s .co m BandCombineOp changeColors = new BandCombineOp(colorMatrix, null); Raster sourceRaster = src.getRaster(); WritableRaster displayRaster = sourceRaster.createCompatibleWritableRaster(); changeColors.filter(sourceRaster, displayRaster); return new BufferedImage(src.getColorModel(), displayRaster, true, null); } }