c++ - Converting UINT32 color format from AaBbGgRr to AaRrGgBb -


i trying convert uint32 color format aabbggrr aarrggbb in c++. aa = alpha, bb = blue, gg = green rr = red. converting mean switching values of bb , rr. know how can achieve ?

you can use mask , bit shifting achieve this:

uint32_t newvalue = oldvalue;  newvalue = newvalue & 0xff00ff00; // open new space insert bits newvalue = ((oldvalue & 0xff)<< 16) | newvalue; // change bb  newvalue = ((oldvalue & 0x00ff0000) >> 16) | newvalue; // change rr 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -