1 2 | import java.awt.image.BufferedImage; import java.awt.Color; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | public static BufferedImage hue(BufferedImage source, float value){ BufferedImage out = new BufferedImage(source.getWidth(), source.getHeight(), source.getType()); for ( int i = 0 ; i < source.getWidth(); i++){ for ( int j = 0 ; j < source.getHeight(); j++){ Color color = new Color(source.getRGB(i, j)); float [] hsb = new float [ 3 ]; Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb); hsb[ 0 ] += value; color = Color.getHSBColor(hsb[ 0 ], hsb[ 1 ], hsb[ 2 ]); out.setRGB(i, j, color.getRGB()); } } return out; } |
修改前
before

以 setHue(source, 1F / 3F) 修改後
edit with setHue(source, 1F / 3F)

以 setHue(source, -1F / 3F) 修改後
edit with setHue(source, -1F / 3F)

沒有留言 :
張貼留言