Showing posts with label RGB to long. Show all posts
Showing posts with label RGB to long. Show all posts

Tuesday, June 14, 2011

RGB to long and Long to RGB

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;



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