c++, how to store ARGB in 1 int.


SUBMITTED BY: Guest

DATE: Nov. 21, 2013, 2:58 p.m.

FORMAT: C++

SIZE: 521 Bytes

HITS: 996

  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. //Creating in with argb values from 0 to 255
  5. int argb = (255&0xff) + //ALPHA
  6. ((200&0xff)<<8) + //RED
  7. ((150&0xff)<<16) + //GREEN
  8. ((100&0xff)<<24); //BLUE
  9. cout << "ALPHA = " << (argb&0xff) << endl;
  10. cout << "RED = " << ((argb>>8)&0xff) << endl;
  11. cout << "GREEN = " << ((argb>>16)&0xff) << endl;
  12. cout << "BLUE = " << ((argb>>24)&0xff) << endl;
  13. cin.get();
  14. return 0;
  15. }

comments powered by Disqus