Java examples for 2D Graphics:Color
blur Color
//package com.java2s; import java.awt.Color; public class Main { /**/* www .j a v a 2s . c o m*/ * */ public static Color blurColor(Color color) { int[] rgb = colorToRGB(color); int average = (rgb[0] + rgb[1] + rgb[2]) / 3; rgb[0] = (rgb[0] + average * 2) / 3; rgb[1] = (rgb[1] + average * 2) / 3; rgb[2] = (rgb[2] + average * 2) / 3; return rgbToColor(rgb); } public static int[] colorToRGB(Color color) { int[] rgb = new int[3]; rgb[0] = color.getRed(); rgb[1] = color.getGreen(); rgb[2] = color.getBlue(); return rgb; } /** * */ public static Color rgbToColor(int[] rgb) { return new Color(rgb[0], rgb[1], rgb[2]); } }