|
Post by johnno56 on Feb 28, 2022 14:12:25 GMT -6
When I print out the value of black (rgb(0,0,0)) I get: 4294967091 and for white (rgb(255,255,255)) I get: 4294967295
Is there a way to convert the decimal number back into an rgb() value? Just curious.
I was of the opinion that the minimum/maximum values of rgb() are from 0 to 256x256x256 (16777216)
|
|
|
Post by rosy on Feb 28, 2022 15:54:17 GMT -6
I get 4278190080 for RGB(0,0,0)...
|
|
|
Post by n00b on Feb 28, 2022 16:12:40 GMT -6
RGB(0,0,0) is equivalent to RGBA(0,0,0,255)
|
|
|
Post by johnno56 on Mar 1, 2022 1:00:09 GMT -6
Ah... So... The number 429486.... etc includes alpha? 256x256x256x256... cool...
|
|
|
Post by n00b on Mar 1, 2022 1:35:29 GMT -6
The colors are in the order Alpha, Red, Green, Blue.
Here is an example of how to extract each color using bit shifting:
color = RGB(20, 30, 40)
r = AndBit(color shr 16, 255) g = AndBit(color shr 8, 255) b = AndBit(color, 255) a = AndBit(color shr 24, 255)
Print "Red = ";r Print "Green = ";g Print "Blue = ";b Print "Alpha = ";a
|
|
|
Post by rosy on Mar 1, 2022 2:41:03 GMT -6
You've realized that we've got different values?
|
|
|
Post by aurel on Mar 1, 2022 2:50:19 GMT -6
what about this method :
Function RGB(byval red as INT,byval green as INT,byval blue as INT) as INT INT color color = red color = color + green*256 color = color + blue*65536 Return color End Function
|
|
|
Post by rosy on Mar 1, 2022 22:33:04 GMT -6
He mixed up something with these colors. Usually it's probably RGBA or ABGR. C can be easily converted by union. Or something like that:
Uint32 *BASColor; BASColor=&SDLColor; Uint32 RGBA(R,G,B,A) {SDLColor.r=R;SDLColor.b=B;SDLColor.g=G;SDLColor.a=A;return *BASColor;}
Instead of a structure, it can be an array ...
|
|