1 2 | import java.awt.image.BufferedImage; import java.awt.Color; |
1 2 3 4 5 6 7 8 9 | 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)

沒有留言 :
張貼留言