Java examples for 2D Graphics:BufferedImage Color
shift Hue BufferedImage
//package com.java2s; import java.awt.Color; import java.awt.image.BufferedImage; public class Main { private static final float STEP_SIZE = 7F / 10F; public static void shiftHue(BufferedImage img, int amount) { float[] hsb = new float[3]; for (int x = 0; x < img.getWidth(); x++) { for (int y = 0; y < img.getHeight(); y++) { Color color = new Color(img.getRGB(x, y), true); Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb); hsb[0] = (hsb[0] + (STEP_SIZE * amount)) % 1.0F; img.setRGB(x, y, Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); img.getAlphaRaster().setPixel(x, y, new int[] { color.getAlpha() }); }//from w ww. j a v a 2 s . c om } } }