convert rgb to a single value

Solutions on MaxInterview for convert rgb to a single value by the best coders in the world

showing results for - "convert rgb to a single value"
Julia
06 Sep 2017
1# To encode
2
3rgb = red;
4rgb = (rgb << 8) + green;
5rgb = (rgb << 8) + blue;
6
7# To decode 
8
9red = (rgb >> 16) & 0xFF;
10green = (rgb >> 8) & 0xFF;
11blue = rgb & 0xFF;