import java.awt.image.BufferedImage; import java.awt.Color;
public static BufferedImage getColorChannel(BufferedImage source, Color color){ BufferedImage out = new BufferedImage(source.getWidth(), source.getHeight(), source.getType()); for (int i = 0; i < out.getHeight(); i++) { for (int j = 0; j < out.getWidth(); j++) { out.setRGB(i, j, (source.getRGB(i, j) & color.getRGB())); } } return out; }
修改前
before
以 getColorChannel(source, Color.RED) 修改後
edit with getColorChannel(source, Color.RED)
以 getColorChannel(source, Color.GREEN) 修改後
edit with getColorChannel(source, Color.GREEN)
以 getColorChannel(source, Color.BLUE) 修改後
edit with getColorChannel(source, Color.BLUE)
沒有留言 :
張貼留言