2

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.

enter image description here

Ozzy
  • 8,244
  • 7
  • 55
  • 95
BuZz
  • 16,318
  • 31
  • 86
  • 141

2 Answers2

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

Community
  • 1
  • 1
Ozzy
  • 8,244
  • 7
  • 55
  • 95
0

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

Community
  • 1
  • 1
Jens Egholm
  • 2,730
  • 3
  • 22
  • 35