Home    |    Concepts   |   API   |   Samples
Concepts > Rasters > Basic Principles
Color Maps

A color map is a color lookup table, in which every entry specifies a color by a red, green, and blue value in the RGB color model. The values can range from 0.0 to 1.0 in floating point values or from 00 to FF in hexadecimal values. A fourth value, the alpha value, defines opacity. It also ranges from 0.0 to 1.0; 0.0 meaning the color is fully transparent, and 1.0 that the color is fully opaque. A color map usually stores 256 different RGBA-tupels, but other sizes and even procedurally-defined color maps are possible too.

When a color map is in use, the pixel values represent an index to the color map. For instance, a pixel value of 16 would index the sixteenth element of the color map. The application renders the pixel according to the intensity of colors defined by the color map element.

There are different types of color maps.

  • SE_COLORMAP_NONE means that a color map is not defined for this image. This is the default. Use this enumeration to undefine an existing color map.
  • SE_COLORMAP_RGB represents a three color intensity map.
  • SE_COLORMAP_RGBA represents a three color intensity map and a fourth element that defines transparency.

Several data types can be used to store color map values.

  • SE_COLORMAP_DATA_BYTE data type is used to store data as unsigned character.
  • SE_COLORMAP_DATA_SHORT data type is used to store data as unsigned short (2 byte) integer.

Color maps can only be applied to rasters with a single raster band and are not verified by the ArcSDE server. It is the responsibility of the application to verify the values contained in the color map.

If the color map type is SE_COLORMAP_RGB, it should have the following structure:

r0, g0, b0

r1, g1, b1

...

rn, gn, bn

Whereas, if the color map type is SE_COLORMAP_RGBA, it should have the following structure:

r0, g0, b0, t0

r1, g1, b1, t1

...

rn, gn, bn, tn

The ArcSDE Raster API provides functions to set the color map for a particular raster. These functions are used during creation of a raster or when data is loaded into a raster through the RasterAttr object.

prepare_colormap (colormap_type,
colormap_data_type,
num_colormap_entities,
colormap_data_uchar);

ret = SE_rasterattr_set_colormap (*raster_attrib,
colormap_type,
colormap_data_type,
num_colormap_entries,
(void *) colormap_data_uchar);
SeRasterAttr attr = ........;

int numBanks = 3;
int numEntries = 256;

DataBufferByte dataBuffer = new DataBufferByte(numEntries, numBanks);

for(int elem=0; elem < numEntries; elem++)
{
    for(int bank=0; bank < numBanks; bank++)
    {
        dataBuffer.setElem(bank, elem, (int)elem);
    }
}

attr.setColorMap(SeRaster.SE_COLORMAP_RGB, dataBuffer);

The SeRasterBand.setColorMap() or SE_rasbandinfo_set_colormap() function can be used when changes are being made to an existing raster by altering an existing raster band.

Coming soon
SeRasterBand band = ......;

int numBanks = 3;
int numEntries = 256;

DataBufferByte dataBuffer = new DataBufferByte(numEntries, numBanks);
for (int elem=0; elem < numEntries; elem++)
{
    for (int bank=0; bank < numBanks; bank++)
    {
        dataBuffer.setElem (bank, elem, (int) elem);
    }
}

band.setColorMap(SeRaster.SE_COLORMAP_RGB, dataBuffer);

In both cases, it is mandatory that there be only one raster band in the raster. If there is more than one band in the raster and a color map must be set, the other remaining raster bands must be deleted.

feedback | privacy | legal