Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / RGB Function

Author
Message
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 9th Mar 2004 21:56 Edited at: 9th Mar 2004 21:57
Could someone briefly explain how the RGB funciton works i quickly scanned the internet but didn't find anything reasonable. So basically how do these two equate?

rgb(255,255,255) = 4,294,967,295

thanks

zircher
22
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 9th Mar 2004 22:47
Ok, a byte (8 bits) can range from 0 to 255.

A number stored in binary does the ol' power of two thing.

So, 255,255,255 becomes FF,FF,FF in hex or binary
11111111, 11111111, 1111111.

11111111111111111111111 is a very big number in binary.
--
TAZ

hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 10th Mar 2004 00:05 Edited at: 10th Mar 2004 00:14
Quote: "11111111111111111111111 is a very big number in binary"


but not quite big enough unless my math is rusty i'd say the decimal equivalent of the binary above is "16,777,215" (same for FF FF FF in hex i guess) which is still pretty far from "4,294,967,295"

dunno, i might be wrong though

hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 10th Mar 2004 00:37
it's about 33 1's in a row:

11111111 11111111 11111111 11111111 1

if the first set of 8 bits if for red, the next for green and the last for blue then how about the final 9 bits?

zircher
22
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 10th Mar 2004 00:59
Ah, the alpha channel for 32 bit colors, basically the transparency setting.
--
TAZ

hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 10th Mar 2004 01:09 Edited at: 10th Mar 2004 01:21
cool

[edit]

anyone else interested, manual calculation of the RGB value is:

rgbVal = blue + (green*256) + (red*65536) + alpha

where the alpha is 4278190080, the last 9 bits:

(2^32)+(2^31)+(2^30)+(2^29)+(2^28)+(2^27)+(2^26)+(2^25)+(2^24)

Login to post a reply

Server time is: 2025-05-23 14:35:00
Your offset time is: 2025-05-23 14:35:00