Resolution / Palettes / Pixel Storage Topics
 
 
 

Bitmap Adjustment - Changes to Resolution and Color Depth

There are several ways to change the resolution of a bitmap. In each case this involves creating a new bitmap and copying the existing bitmap to the new. To change the image size without any scaling of the pixel data, use Bitmap::CopyImage() and specify the COPY_IMAGE_CROP operation. To resize the bitmap you use Bitmap::CopyImage() as well. This method lets you specify either a low quality (faster) or a higher quality (slower) copy. See Copy Image Operations for examples of each.

To change the color depth (number of bits per pixel), you must create a new bitmap of the desired color depth, and copy the original to the new using Bitmap::CopyImage().

Palettes

Some color bitmaps use only 8-bits per pixel. These images, unlike true color images where every pixel can be a unique color, are limited by the colors stored in a palette. For example, an 8-bit GIF file has a 256 color palette. The color values stored by the palette can be any color, but the actual bitmap image can only be comprised of colors from the palette. And since the palette is limited to 256 colors, the image has a maximum of 256 unique colors. For paletted bitmaps, each pixel in the image is actually an index into the palette (sometimes called a color lookup table). So the pixel value tells the system which palette slot to look in, and the value in that palette slot determines the exact color.

In contrast, true color images, for example a 24-bit TGA file, store the color of the pixel directly in the pixel value. There is no palette used.

In 3ds Max, every bitmap has storage for a palette even if it is not used. There are methods of the Bitmap class used to work with palettes. A developer may use Bitmap::IsPaletted() to determine if an image is indeed paletted. To access the palette of a bitmap, Bitmap::GetPalette() and Bitmap::SetPalette() may be used.

Palettes are primarily a concern for image loader plug-in derived from BitmapIO. When loading an 8 bit image, the loader would create an 8-bit storage and set the palette through BitmapStorage::SetPalette(). Sample code is available showing how this is done in \MAXSDK\SAMPLES\IO\BMP\BMP.CPP in the Load() method.

Pixel Storage

There are several in-memory storage formats for pixel data. For a list of the available formats see the section Pixel Storage Types .