One way is (off the top of my head)


rgbValue = 65535

red = rgbValue & 0xf800 >> 11

green = rgbValue & 0x07e0 >> 5

blue = rgbValue & 0x001f

I'm sure I'll think of others when the pressure is off.
Unfortunately, that doesn't seem to work :(
If I substitute (for example) the value 43039, r, g, and b still equal 31, so it apparently only works for 65535...