Page 1 of 1

How to convert unsigned 4-byte to decimal

Posted: Fri May 16, 2008 1:35 pm
by Rafael Clemente
I have a 4 byte, unsigned number (it is an OLE_COLOR data) that I'd like to convert it to RGB format in the range 0-16777215
Anybody could suggest a function to do it?
Thanks
Rafael

Posted: Fri May 16, 2008 5:13 pm
by Antonio Linares
Rafael,

Try it this way:

nLoWord( nNumber ) + ( 256 * nHiWord( nNumber ) )

or doing:

nHiWord( nNumber ) + ( 256 * nLoWord( nNumber ) )

It depends on the bytes storage order