Answer the question
In order to leave comments, you need to log in
Java. Convert color to black and white. Can you help?
So I'm writing a game in which you can turn on the hunter's vision. It assumes that most of all the colors on the screen will become black and white, and only a few will be displayed.
And then questions arise:
How to turn a color of type Color into one line into black and white?
How to do the same with an Image, changing each of its pixels to the appropriate black and white tint?
Please describe in more detail, as I do not rummage much in this topic! Thanks in advance :)
Answer the question
In order to leave comments, you need to log in
Well, in general, if you have an RGB color, then making it black and white is simple - you need to put the average value in R and G and B.
Those. or consider the arithmetic mean RGB and put it in all channels. Or - using coefficients (like such - Y = 0.2125 R + 0.7154 G + 0.0721 B).
But usually in games this is done with a shader. With the same logic.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question