Wednesday, March 9, 2011

Store RGB values ( color values ) in a single variable and retrevie it back

bool ReadColor( long nDecimal, int& nRVal, int& nGVal, int& nBVal )
{

/*nAVal = nDecimal & 0x000000FF;
nDecimal = nDecimal>>8;*/

nRVal = (nDecimal)& 0x000000FF;
nDecimal = nDecimal>>8;

nGVal = nDecimal & 0x000000FF;
nDecimal = nDecimal>>8;

nBVal = nDecimal & 0x000000FF;

return true;

}

bool CreateColor(long &nDecimal, int nRVal, int nGVal, int nBVal )
{


nDecimal = (nDecimal)& 0x00000000;
nDecimal = (nDecimal) | nBVal;
nDecimal = nDecimal<<8;
nDecimal = (nDecimal) | nGVal;
nDecimal = nDecimal<<8;
nDecimal = nDecimal | nRVal;
return true;

}