Change color of non-transparent parts of png in Java

前端 未结 3 1332
遥遥无期
遥遥无期 2021-01-31 11:17

I am trying to automatically change the color for a set of icons. Every icon has a white filled layer and the other part is transparent. Here is an example: (in this case it\'s

3条回答
  •  长情又很酷
    2021-01-31 11:35

    The problem is, that

    Color originalColor = new Color(image.getRGB(xx, yy));
    

    discards all the alpha values. Instead you have to use

     Color originalColor = new Color(image.getRGB(xx, yy), true);
    

    to keep alpha values available.

提交回复
热议问题