Extracting RGB from Short

Hi,
I need to know how to extract the red, green, and blue values from a short (16-bit color). Can anybody tell me?

5 first is red, 6 next is green and the five last is blue.

r = (rgb & 0xF800) >> 11;
g = (rgb & 0x7E0) >> 5;
b = (rgb & 0x1F);

maybe bitshifting and then anding is more correct, don’t know :slight_smile:

crossposting >:(