Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hexadecimal Woes
I'm working with coloring some reports and have been trying to define
colors (via enum) for them. 1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX? Example: &H996633 = 10053171 RGB(153,102,51) = 3368601 RGB(51,102,153) = 10053171 2) Why is it that &HCCFF appears to be (what I think is) the two's compliment to 0xCCFF? &HCCFF = -13057 -13057 = -0x3301 0x3301 + 0xCCFF = 0x10000 I've got the color issues for my program figured out, I'm just curious about why Excel behaves this way. I did a quick Google search that didn't bring up any complaints about this, so I figure I must not be understanding How Things Work correctly. Thanks for any insight you can offer! -Bryan |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hexadecimal Woes
http://www.mvps.org/dmcritchie/excel/colors.htm
-- Regards, Tom Ogilvy "Bryan Loeper" wrote: I'm working with coloring some reports and have been trying to define colors (via enum) for them. 1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX? Example: &H996633 = 10053171 RGB(153,102,51) = 3368601 RGB(51,102,153) = 10053171 2) Why is it that &HCCFF appears to be (what I think is) the two's compliment to 0xCCFF? &HCCFF = -13057 -13057 = -0x3301 0x3301 + 0xCCFF = 0x10000 I've got the color issues for my program figured out, I'm just curious about why Excel behaves this way. I did a quick Google search that didn't bring up any complaints about this, so I figure I must not be understanding How Things Work correctly. Thanks for any insight you can offer! -Bryan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hexadecimal Woes
While a good resource for color, that page doesn't really answer
either of my questions. On May 18, 2:50 pm, Tom Ogilvy wrote: http://www.mvps.org/dmcritchie/excel/colors.htm -- Regards, Tom Ogilvy |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hexadecimal Woes
1. Each RGB value occupies a byte (0-255). In VB/A RGB values are placed in
order least to most significant byte:- &Hbbggrr In many languages, perhaps the majority, the byte order is reversed. Strangely, some API's use RGB and others BRG. 2. I don't really understand what the question is, and why you are only dealing with two of the three RGB bytes. But, whatever it is, perhaps your confusion might relate to your mixing Integer Hex (2 byte) and Long Hex (4 byte) values &HCCFF = -13057 values 0 to &H7FFF are +ve, 0 to 32767 values &H8000 to &HFFFF are -ve, -32768 to -1 to coerce to a Long add the & &HCCFF& = 52479 = rgb(255,204,000) Regards, Peter T "Bryan Loeper" wrote in message ups.com... I'm working with coloring some reports and have been trying to define colors (via enum) for them. 1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX? Example: &H996633 = 10053171 RGB(153,102,51) = 3368601 RGB(51,102,153) = 10053171 2) Why is it that &HCCFF appears to be (what I think is) the two's compliment to 0xCCFF? &HCCFF = -13057 -13057 = -0x3301 0x3301 + 0xCCFF = 0x10000 I've got the color issues for my program figured out, I'm just curious about why Excel behaves this way. I did a quick Google search that didn't bring up any complaints about this, so I figure I must not be understanding How Things Work correctly. Thanks for any insight you can offer! -Bryan |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Hexadecimal Woes
Ok, I think I understand number 1 as far as theory goes. As for
number 2, whenever I put in &H00CCFF, it always gets shortened to &HCCFF. Thanks for the clarification about the second '&'! It was exactly what I was looking for. -Bryan On May 19, 6:39 pm, "Peter T" <peter_t@discussions wrote: 1. Each RGB value occupies a byte (0-255). In VB/A RGB values are placed in order least to most significant byte:- &Hbbggrr In many languages, perhaps the majority, the byte order is reversed. Strangely, some API's use RGB and others BRG. 2. I don't really understand what the question is, and why you are only dealing with two of the three RGB bytes. But, whatever it is, perhaps your confusion might relate to your mixing Integer Hex (2 byte) and Long Hex (4 byte) values &HCCFF = -13057 values 0 to &H7FFF are +ve, 0 to 32767 values &H8000 to &HFFFF are -ve, -32768 to -1 to coerce to a Long add the & &HCCFF& = 52479 = rgb(255,204,000) Regards, Peter T "Bryan Loeper" wrote in message ups.com... I'm working with coloring some reports and have been trying to define colors (via enum) for them. 1) Why is it that RGB(a,b,c) ends up being in BGR order as HEX? Example: &H996633 = 10053171 RGB(153,102,51) = 3368601 RGB(51,102,153) = 10053171 2) Why is it that &HCCFF appears to be (what I think is) the two's compliment to 0xCCFF? &HCCFF = -13057 -13057 = -0x3301 0x3301 + 0xCCFF = 0x10000 I've got the color issues for my program figured out, I'm just curious about why Excel behaves this way. I did a quick Google search that didn't bring up any complaints about this, so I figure I must not be understanding How Things Work correctly. Thanks for any insight you can offer! -Bryan- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Import hexadecimal data into excel keeping hexadecimal format | Excel Discussion (Misc queries) | |||
Hexadecimal data | Excel Discussion (Misc queries) | |||
Leading Zero in Hexadecimal? | Excel Discussion (Misc queries) | |||
Decimal to Hexadecimal | Excel Discussion (Misc queries) | |||
Hexadecimal to binary | Excel Discussion (Misc queries) |