Converting uint to RGB

Hi everybody, Newb here I'm afraid, that is new to MaxScript, quite experienced scripter. I need to convert a value (uint) to a color to store it in a bitmap. I would normally use bitshift for this and was glad to see it's supported, though I haven't found a usage example. Here's my code:

scaledValue = raw.x * scaler -- large uint, for example 230056


r = bit.and(bit.shift scaledValue 16) 0xFF
g = bit.and (bit.shift scaledValue 8) 0xFF
b = bit.and scaledValue 0xFF

I do get a color, and no errors, but not the right color. 

Any ideas?

Cheers!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
theMightyAtom's picture

Solved! the 16 and 8 need to

Solved! the 16 and 8 need to be minuses, I was shifting the wrong way, "<<" instead of ">>"

Where there's a will, there's a workaround :O)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.