How to convert Colors to Grayscale in java with just the java.io.*; library?

后端 未结 3 647
无人共我
无人共我 2021-01-21 20:09

Well, i got this.. cause in my place they request it like that.. Well i have this: //some variables and coments are a possible code.. But i mean i don\'t know how to do it exact

3条回答
  •  不思量自难忘°
    2021-01-21 20:41

    // constant factors
                final double GS_RED   = 0.299;
                final double GS_GREEN = 0.587;
                final double GS_BLUE  = 0.114;
    

    Now retrieve each and gett it's red, blue, green component and alpha if exist and multiply them with their corresponding factor.

    R = G = B = (int)(GS_RED * R + GS_GREEN * G + GS_BLUE * B);
    

提交回复
热议问题