Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <bitset>
- #include <cstdint>
- #include <SDL2/SDL.h>
- using namespace std;
- int main()
- {
- uint32_t rgba = 0;
- uint8_t r { 0xFF };
- uint8_t g { 0xFF };
- uint8_t b { 0xf4 };
- uint8_t a { 0xFF };
- rgba = (a << 24) + (b << 16) + (g << 8) + r;
- cout << "Final color is " << setfill('0') <<
- setw(4) << hex << rgba << endl;
- cout << resetiosflags(ios::showbase);
- cout << "Binary color is " << bitset<32>(rgba) << endl;
- uint8_t _r = 0;
- _r = rgba & 255;
- uint8_t _g = 0;
- _g = (rgba >> 8) & 255;
- uint8_t _b = 0;
- _b = (rgba >> 16) & 255;
- cout << "r = " << unsigned(_r) << endl;
- cout << "g = " << unsigned(_g) << endl;
- cout << "b = " << unsigned(_b) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement