Advertisement
here2share

# rgb2int+reverse.py

Aug 10th, 2015
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. # rgb2int_reverse.py -- white (255,255,255) = 16777215
  2.  
  3. def rgb2int(rgb):
  4.     return rgb[0] * (256**2) + rgb[1] * 256 + rgb[2]
  5. def int2rgb(dd):
  6.     return (dd // 256 // 256 % 256, dd // 256 % 256, dd % 256)
  7.  
  8. print rgb2int([0,255,255])
  9. print int2rgb(65535)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement