ImageMan DLL Suite Version 8Submit feedback on this topic   

Working with Multiple Images and Palettes

There are two special cases to be aware of when generating and realizing different palettes: when your are displaying two images at once, or when you are using the ImgDrawImageFx function to draw a series of images. In these cases, it is imperative that each image is using the same color palette; if they are not, the images will not display consistently.

There are three things you can do to guarantee that each image has the same color palette:

  1. Make sure the images are saved beforehand with identical color palettes. This is quite easy to do using most any painting program, but is very inflexible, as you must have collected all the images to be displayed beforehand. Note, however, that this is the fastest method, as it requires no image manipulation on the part of ImageMan.

  2. Use the ImgReduceColors function to reduce each of the images to the ImageMan fixed palette (the IMG_FIXEDPALETTE flag). This method is easy to use and flexible, but the resulting images will generally not look their best. If you have a wide range of images to work with (i.e., images which have widely varying color makeup), then you should use this method.

  3. Use the ImgReduceColorsPal function to reduce all of the images to a palette of your choice. This method is slightly more complicated than the IMG_FIXEDPALETTE method, but allows you to select one palette to apply to a range of images. This method is generally most effective when working with many images that have roughly the same color makeup (for instance, several different aerial photographs of an island).

 

Options one and two are pretty straightforward, so we'll only give a sample for option three, using the ImgReduceColorsPal function. To do this, you simply select the first image's palette and then color-reduce and display all the images using that palette.

Here is a sample of reducing two images to one image's palette and using that palette:

// This sample assumes that each image is 256 colors or greater, and

// that you've already gotten an hDC and calculated the display

// rectangles for each image.

int iFlags = IMG_OCTREEPALETTE | IMG_FLOYD ;

hReduce1 = ImgReduceColors ( hImage1, 256, iFlags ) ;

hPal = (HPALETTE) ImgGetPalette ( hReduce1 ) ; // get the reduced palette

// notice that the number of colors for this function is gotten from the

// number of colors in the palette we pass in. The 0 we pass in

// is not used at all...

hReduce2 = ImgReduceColorsPal ( hImage2, iFlags, hPal ) ;

SelectePalette ( hDC, hPal, false ) ; // select it

RealizePalette ( hDC ) ; // now realize it!

ImgDrawImage ( hReduce1, hDC, lpRect1, NULL ) ; // draw the first one

ImgDrawImage ( hReduce2, hDC, lpRect2, NULL ) ; // draw the second one

 

 

 


© 1995-2004 Data Techniques, Inc. All rights reserved.