Applying a tint to an image in java

前端 未结 7 799
太阳男子
太阳男子 2020-12-09 16:25

I am trying to create several similar visual styles for my programs, each with a different color theme. To do this, I have implemented the use of icons to represent the diff

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 16:53

    This isn't exactly tinting, its more like applying another layer on it but it works for me:

    public static BufferedImage colorImage(BufferedImage loadImg, int red, int green, int blue, int alpha /*Also the intesity*/) {
        Graphics g = loadImg.getGraphics();
        g.setColor(new Color(red, green, blue, alpha));
        g.fillRect(0, 0, loadImg.getWidth(), loadImg.getHeight());
        g.dispose();
        return loadImg;
    }
    

提交回复
热议问题