[mapserver-dev] How to force color reduction processing without saving to a file in mapserver library

Stephen Woodbridge woodbri at swoodbridge.com
Sat Oct 24 17:28:48 EDT 2009


Hi all,

I'm using the mapserver library in C to generate an image and chop it 
into tiles. It is working great so far, but I have a question about 
optimizing it.

Currently, I have to save the generated image to a file to force 
mapserver to perform the image processing and color reduction. like:

   OUTPUTFORMAT
     NAME agg
     DRIVER "AGG/PNG"
     EXTENSION "png"
     MIMETYPE "image/png"
     IMAGEMODE RGB
     #FORMATOPTION "INTERLACE=false"
     FORMATOPTION "QUANTIZE_FORCE=ON"
     FORMATOPTION "QUANTIZE_DITHER=OFF"
     FORMATOPTION "QUANTIZE_COLORS=256"
   END


oImg = msDrawMap(map, MS_FALSE);
ret = msSaveImage(NULL, oImg, szMetaImg); // FORCE COLOR REDUCTION

then if loop over the image and chop it into tiles like:

msImageCopyMerge(oTile->img.gd, oImg->img.gd,
    0, 0, tileLeft, tileTop, tileWidth, tileHeight, 100);
ret = msSaveImage(NULL, oTile, buf);

Like I said, this works great, but I would like to avoid doing the extra 
I/O of saving the metatile, if I can just call a function to trigger the 
image reduction. If I do not save the image, then the buffer is still in 
24 bit RBG mode and the tiles are all black on output.

Thoughts?

-Steve W.


More information about the mapserver-dev mailing list