W

X

Thursday, November 23, 2006

Colors

As several people have discovered, the version 3.0 software uses a new color scheme. The new colors have 4 components A, R, G and B. A is the alpha channel (transparency), R for red, G for green and B for blue.

I have been asked about convering html colors to a decimal value. Note: You will probably want to use the windows calculator to convert hex values to decimal. Here is an example.

Alice Blue's html color is #F0F8FF hex or 15792383 decimal. In order to convert this color so that is usable in the WxMap ini file, you need to do the following. Take 15792383 and add 4278190080, which is the alpha channel value (#FF000000), then subtract 4294967296 (#100000000). This results in the value -984833. This value can be used in the WxMap.ini file.

Note: The alpha channel's value 255 (#FF) represents no transparency.

The proper representation of this value in hex is FF,F0,F8,FF. This is the ARGB format.

You can convert one component at a time as follows.
FF = 255 * 16777216 = 4278190080
F0 = 240 * 65536 = 15728640
F8 = 248 * 256 = 63488
FF = 255 * 1 = 255
Value = 4293982463
Subtract 4294967296
ARGB = -984833

You can convert from ARGB to the individual componets. It is important to remember that if the number is negative, you first need to add 4294967296 (#100000000). Once this addition has occurred, you can plug that decimal number into the windows calculator and click the Hex button to get each hexadecimal pair.

Note: In windows calculator, click view, then select scientific. This gives you the hex to decimal and decimal to hex conversion options.

No comments: