Integer to RGB components

Started by
1 comment, last by gaerg 14 years, 4 months ago
How do I convert an integer value to r, g and b components? E.g. GetRed(16777215); Would return 255. And similar functions for green and blue.
Advertisement
This is hiow I convert between long and rgb

	CRgb( unsigned long Color )	{		this->rgbAlpha = static_cast<unsigned char>( (Color >> 24 ) & 0xFF );		this->rgbRed   = static_cast<unsigned char>( (Color >> 16 ) & 0xFF );		this->rgbGreen = static_cast<unsigned char>( (Color >>  8 ) & 0xFF );		this->rgbBlue  = static_cast<unsigned char>( Color          & 0xFF );	}


Now I look at it, you can actully leave out the first bitand with 0xFF
Ron AF Greve
Thanks it works great! I googled for that like an hour without any results.

This topic is closed to new replies.

Advertisement