Qbasicnews.com

Full Version: rgb values and threading question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I looked through the documentation and couldn't find a way to get the rgb values from a number. I want a function that it can give a colour value and have it be able to split back the red, green, and blue components of it. I thought I saw one a while back but didn't pay much attention to it because I wasn't using medium colour.

I am using 16 bits, anybody who knows the formula (or FB command) that could do this, may I have it, I am not very experienced in this colour range.

Just so that I know, how many people out there actually have a multithreaded, or hyperthreaded machine. I can speed up my Inspiration engine incredibly if I can run multiple threads at once, but it doesn't seem worth it if very few people will be able to run it.
Color Value = 65536 * RR + 256 * GG + BB

use MOD and \ to get the values from it.
for 24 or 32 bit colour use something like:

rgb=(red shl 16)or(green shl 8)or blue

red=(rgb and &hff0000) shr 16
green=(rgb and &hff00) shr 8
blue=rgb and &hff

red/green/blue=0-255

for 16 bit colour there's a couple of different formats, 5.5.5 and 5.6.5


for 5.5.5 use:

rgb=(red shl 10)or(green shl 5)or blue

red=(rgb and &h7c00) shr 10
green=(rgb and &h3e0) shr 5
blue=rgb and &h1f

red/green/blue=0-31


and for 5.6.5 use:

rgb=(red shl 11)or(green shl 5)or blue

red=(rgb and &hf800) shr 11
green=(rgb and &h7e0) shr 5
blue=rgb and &h1f

red/blue=value from 0-31
green=0-63

hopefully i got all my numbers right there.
There's no reason inspiration shouldn't run fine in a single thread. Very few people own ht computers, as they're mostly for small network servers and "power" computers for gullible people.

It might, however, make your code more organized, so it's really up to you.