You are viewing our Forum Archives. To view or take place in current topics click here.
{C++} Need help storing rgba as long
Posted:
{C++} Need help storing rgba as longPosted:
Status: Offline
Joined: Apr 05, 201113Year Member
Posts: 822
Reputation Power: 38
Status: Offline
Joined: Apr 05, 201113Year Member
Posts: 822
Reputation Power: 38
I'm trying to store rgba as long in c++. So basically red is 255 0 0 0, but how would that be stored? Would I be able to store it as something else and parse it to long? Any help is appreciated.
#2. Posted:
Status: Offline
Joined: Jul 12, 201013Year Member
Posts: 3,612
Reputation Power: 173
Status: Offline
Joined: Jul 12, 201013Year Member
Posts: 3,612
Reputation Power: 173
What do you mean? Each value represents something, a long is a datatype, so the only thing I can think you mean is long 255000; What do you mean?
- 1useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Aug 14, 200914Year Member
Posts: 1,291
Reputation Power: 65
Status: Offline
Joined: Aug 14, 200914Year Member
Posts: 1,291
Reputation Power: 65
struct RGBA
{
unsigned char red, green, blue, alpha;
};
int main()
{
RGBA color = { 0, 0, 0, 0xFF };
long rgbaVal = *(long*)&color
cout << hex << rgbaVal << endl;
return 0;
}
- 2useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.