MapInfo Products KnowledgeBase

Product: MapX
Version: 3.x/4.x
Platform: All Win32 Platforms
Category: Documentation

Converting between RGB and BGR values for MapX.

MapX uses OLE_COLOR values represented in BGR values, MapInfo tables use colors represented by RGB values. How is it possible to convert back and forth between the two?

An OLE_COLOR value is a BGR (Blue, Green, Red) value. To determine the BGR value, specify blue, green, or red (each of which has a value from 0 - 255) in the following formula:

BGR value = (blue * 65536) + (green * 256) + red

Note: In the MapBasic programming environment, please note that MapBasic uses the following formula to calculate the RGB values:

RGB value = (red * 65536) + (green * 256) + blue

If working with RGB color values (e.g. values used with a MapBasic application), it will be necessary to convert the colors to BGR before those color values can be used in MapX.

Easiest way to calculate these values back and forth:

1. Use the Windows calculator in scientific view.
2. Type in the RGB color in decimal mode e.g.: 12345678
3. Switch to hexadecimal, write down value in window e.g.: BC614E
4. Think of it this way now:

The Green value is a constant center value in RGB and BGR values, so by getting the hex value of 12345678 which equals BC614E, it is possible to switch the first two and the last two values of BC614E and retype them in the calculator in hex mode, (4E61BC) then switch it back to decimal mode and the BGR value will be represented (5136828).

Last Modified: 06/02/2000 07:01:13 PM
Document URL:

Converting between RGB and BGR values for MapX.^8C5BEBBC987D60BC85256802007C3AAE^Y