Graphics aren't my thing, I'm afraid. Actually, nothing is really "my thing," when it comes to programming.
I dug around a bit, and found that the PBCC4.04 function RGB() does not have a true inverse function; there is a BGR() function, but that does something different.
Those of you who do graphics programs probably know about RGB():
long RGB(r, g, b)
where r, g, and b are (integer?) color values from 0 to 255.
What I need is a function that takes a long integer (that is an RGB color value) and splits it back into its constituent r, g, and b values, which I can then manipulate and do whatever with.
Is there actually a formula for this out there already, or is this going to involve some code breaking? I printed out the value of the RGB() function six times with various values for the r, g, and b values to see if there was an obvious pattern, but there isn't as far as I can see:
RGB(0,0,0)=0 (this doesn't defy logic)
RGB(1,1,1)=65793 (OK, a bit unexpected)
RGB(10,10,10)=657930 (very unexpected)
RGB(12,34,56)=3678732 (not very enlightening)
RGB(10,20,30)=1971210 (ditto)
RGB(13,25,46)=3021069 (still in the dark)
So there we have it. I'm hoping that someone else has run into this before; otherwise I may have to write a program to crack the pattern (if there is one), which is going to be painful.
Any thoughts?
I dug around a bit, and found that the PBCC4.04 function RGB() does not have a true inverse function; there is a BGR() function, but that does something different.
Those of you who do graphics programs probably know about RGB():
long RGB(r, g, b)
where r, g, and b are (integer?) color values from 0 to 255.
What I need is a function that takes a long integer (that is an RGB color value) and splits it back into its constituent r, g, and b values, which I can then manipulate and do whatever with.
Is there actually a formula for this out there already, or is this going to involve some code breaking? I printed out the value of the RGB() function six times with various values for the r, g, and b values to see if there was an obvious pattern, but there isn't as far as I can see:
RGB(0,0,0)=0 (this doesn't defy logic)
RGB(1,1,1)=65793 (OK, a bit unexpected)
RGB(10,10,10)=657930 (very unexpected)
RGB(12,34,56)=3678732 (not very enlightening)
RGB(10,20,30)=1971210 (ditto)
RGB(13,25,46)=3021069 (still in the dark)
So there we have it. I'm hoping that someone else has run into this before; otherwise I may have to write a program to crack the pattern (if there is one), which is going to be painful.
Any thoughts?
Comment