mIRC Home    About    Download    Register    News    Help

Print Thread
#108282 18/01/05 06:31 PM
Joined: Jan 2004
Posts: 3
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Jan 2004
Posts: 3
Why do colors in palette slot #7 & 10 display using a color with the Red and Blue values swapped?

$color(7) -> 32764 (0x007FFC)
Draws with color 16547584 (0xFC7F00)

$color(10) -> 9671424 (0x939300)
Draws with color 37779 (0x009393)

#108283 18/01/05 07:01 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
It's because $color() returns the colour in what is, strictly speaking, bgr format, with the highest-byte containing the blue information and the lowest-byte containing the red. It's not specific to colours 7 and 10, it's the same for all of them. This is not a bug, it's a common format for storing RGB values as a single number, often called an 'RGB triple'.

Here's a simple example of a conversion from an RGB triple to the traditional hex representation:
Code:
tokenize 44 $rgb($color(7))
echo -a $base($calc($1 * (2^16) + $2 * (2^8) + $3), 10, 16)


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#108284 18/01/05 07:40 PM
Joined: Jan 2004
Posts: 3
C
Self-satisified door
OP Offline
Self-satisified door
C
Joined: Jan 2004
Posts: 3
OK that makes sence smirk I checked other colors on my pallete but forgot to check, if they were the same stored rgb or bgr. Opps! blush


Link Copied to Clipboard