Java : How to tint this PNG programmatically?

匿名 (未验证) 提交于 2019-12-03 00:59:01

问题:

Within the frame of a chess applet, I have a few sets of such greyscale/black & white (not sure) :

Is there any way to give a color tint to a PNG picture via Java Code ? Tried to google the matter and didn't find anything really matching what I'm looking for.

For the following piece for example, I'd like to give it white/yellow tint for the White player, and a flavour of black for the Black player. The idea of setting the color dynamically is to tweak themes at runtime.

回答1:

It would be a lot simpler to give your program translucent images (PNG) which are plain coloured (plain or gradient) in the colours you want, and have a certain % of transparency (you can do that in photoshop/illustrator in 1min).

Then programmatically merge the tint image (preserving transparency) with the other image underneath.

Check this SO post for how to merge two images: Merging two images



回答2:

I found this on StackOverflow. It's pretty good explanation, so I won't bore you with any additional details :) Hope that helps: Applying a tint to an image in java



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!