Original Post
hello, i have an integer id running from 0 to 32768 (short). now i want to de/encode a 5 Bit RGB color into that range. since 2^5 is 32 and 32*32*32 is 32768 this should be possible. :) i was thinking about using the first 5 bits for red, the next 5 bits for green and the last 5 bits for blue. unfortunately i am extremly bad with bitshifts and bitmasks so i have no idead how to code that and would be very thankful if anyone could provide me with these function: color getColorFromId(short id) { ... } short getIdFromColor(byte red, byte green, byte blue) { ... }