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

Steve Lime Steve.Lime at dnr.state.mn.us
Mon Oct 26 19:43:19 EDT 2009


The image buffer will always be in 24 or 32 bit mode I think. You can write the image
to a in memory buffer with msSaveImageBuffer but I don't think that gets you anywhere.

You could just use GD functions after the drawMap() to reduce and chop I suppose.

Steve

>>> On 10/24/2009 at 4:28 PM, in message <4AE37190.1070907 at swoodbridge.com>,
Stephen Woodbridge <woodbri at swoodbridge.com> wrote:
> 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.
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org 
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev



More information about the mapserver-dev mailing list