Foundation > Graphic Formats > IlvBitmapData: The Portable Bitmap Data Management Class > The IlvIndexedBitmapData Class
 
The IlvIndexedBitmapData Class
The IlvIndexedBitmapData class is dedicated to indexed color images, where raster data is described as indexes to a color map (8-bit values, meaning that you can have only 256 colors in an indexed bitmap data).
Creating an Indexed Bitmap Data of Dimensions 256 * 256 Pixels
The first step is to create a colormap. We create a colormap with 256 entries. We then fill this colormap with grayscale values. Each component is described using 8 bits for each component.
IlvColorMap* cmap = new IlvColorMap(256);
for (IlUInt idx = 0; idx < 256; ++idx) {
// sets the red, green and blue components for a entry
cmap->setEntry(idx, idx, idx, idx);
}
We then create an indexed bitmap data of desired size:
IlvIndexedBitmapData* idata = new IlvIndexedBitmapData(256, 256, cmap);
We then fill the bitmap data with a gradient of indexes:
for (IlUInt h = 0; h < 256; ++h)
for (IlUInt w = 0; w < 256; ++w)
idata->setPixel(w, h, h);
To be able to display this bitmap data on the screen, you have to create an IlvBitmap from it.
IlvBitmap* bitmap = new IlvBitmap(display, idata);
You can then use the IlvIcon class to create a graphic object from this.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.