|
Posted by Steve on 01/16/07 23:57
"Onideus Mad Hatter" <usenet@backwater-productions.net> wrote in message
news:jfmqq2153i7n8lp8i9f0522rs1c92ab50g@4ax.com...
| On 13 Jan 2007 03:48:29 GMT, jasen <jasen@free.net.nz> wrote:
|
| >On 2007-01-12, Onideus Mad Hatter <usenet@backwater-productions.net>
wrote:
| >> On 12 Jan 2007 02:26:05 -0800, sl@f0r7r355.org wrote:
| >
| >> ...wow...even Wikipedia FAILS to explain it with anything other than
| >> the most simplistic glazing jive of redundant incoherency. Tsch,
| >> tsch, tsch...a simple formula/equation is just TOO MUCH to ask
| >> apparently. Oh how the mighty web has fallen.
| >>
| >
| >Binary RGB:
| >
| > RGB colours are represented in the low 24 bits of a 32-bit number
| >
| > 8bits for red
| > 8bits for green
| > 8bits for blue
| >
| > to convert 8-bit unsigned (0..255) R,G, and B values to an RGB value
| > you need to shift the red 16 bits and the green 8 bits to the left
| >
| > this means multiplying red by 65536 and green by 256 and then adding
| > them all up.
| >
| >one easy way to do this is to write them in hex.
|
| So let's use the base numbers:
| 13
| 162
| 189
|
| The formula you just gave: (r * 65536)+(g * 256)
|
| The formula you gave before:
| var rgb : String = "0x" + ((r*256+g)*256+b).toString(16);
|
| In the first we get:
| (13 * 65536)+(162 * 256) = 893440
|
| In the second we get:
| (13*256+162)*256+189 = 893629
|
| Convert the two to hex:
| 0DA200
| 0DA2BD
|
| And then convert the two digit hex codes back to decimal:
| 13,162,0
| 13,162,189
|
| Ahhh, I see where you failed, you forgot to mention that you needed to
| ADD the blue. So the formula should ACTUALLY be:
| (r * 65536)+(g * 256)+b
| or you can alternatively write it as:
| (r*256+g)*256+b
|
| So that's good, we have a formula now...we're still missing the
| EXPLANATION however. You said:
|
| > to convert 8-bit unsigned (0..255) R,G, and B values to an RGB value
| > you need to shift the red 16 bits and the green 8 bits to the left
|
| ...but what you don't say is WHY. What ~exactly~ is the correlation
| between the two? I mean I understand RGB, each represents a base
| additive color with a range between 0 and 255. But what EXACTLY are
| these multiplied values in relation to their original RGB values? Is
| it just mathematical parlor tricks to shorten the amount of bits that
| represent each color or is there some ACTUAL meaning behind the
| numbers?
i unplonked you to see what you were up to...and i found this gem. all i can
say is OH MY FUCKING GAWD !!!
how fucking stupid are you? do you not understand why you are using the
values 65536 and 256 in your calculation - and given the two explanations
you originally got, you should have KNOWN to add blue, dipshit! second, do
you not understand what bit shifting does? do you know what words are when
speaking of computer numbers like integers and longs?
of course fucking not. so here's your spanking. if you evenly divide an
integer (into bits), you can then massage a section of the number (a portion
of the bits) virtually independent of the other bits. say that we want to
store R, G, and B as one digit. if you say that R begins at 65536, and that
G will be from 256 to 65535, and B is from 0 to 255, then you can safely
alter one range without effecting the others. the bit shifting aids in this
should you want to make programming easier to read. ex.
R = 10
G = 10
B = 10
the math:
R = R << 16
G = G << 8
// B = nothing to do here b/c bits 0 to 8 are reserved for B
do you have a fucking clue now? perhaps you should have read jasen's advice
more closely (if you can read):
"this means multiplying red by 65536 and green by 256 and then adding them
all up"
especially the 'adding them ALL up'. that would have kept you from
blathering:
'Ahhh, I see where you failed, you forgot to mention that you needed to ADD
the blue. So the formula should ACTUALLY be: (r * 65536)+(g * 256)+b'
you fucking idiot. YOU FAILED TO READ, dumbass-shit-for-brains. your mouth
is the only functioning feature on your head...and how it does go on.
oh well, back to plonking you. your response would be another good laugh
however.
Navigation:
[Reply to this message]
|