Answers for "convert rgb to a single value"

1

convert rgb to a single value

# To encode

rgb = red;
rgb = (rgb << 8) + green;
rgb = (rgb << 8) + blue;

# To decode 

red = (rgb >> 16) & 0xFF;
green = (rgb >> 8) & 0xFF;
blue = rgb & 0xFF;
Posted by: Guest on May-07-2021

Python Answers by Framework

Browse Popular Code Answers by Language