from int2rgb by Georg D
two functions. one converts an integer to rgb values, the other one converts rgb into an integer.

int2rgb(colorInt)
function [curR curG curB] = int2rgb(colorInt)

if colorInt > 16777215 || colorInt < 0
    error ('only values <= 16777215 are allowed')
end
curR = floor(colorInt / (256*256));
curG = floor((colorInt - curR*256*256)/256);
curB = colorInt - curR*256*256 - curG*256;

Contact us