How to force color reduction processing without saving to a file in mapserver library

2 messages Options
Embed this post
Permalink
Stephen Woodbridge

How to force color reduction processing without saving to a file in mapserver library

Reply Threaded More More options
Print post
Permalink
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-dev
Steve Lime

Re: How to force color reduction processing withoutsaving to a file in mapserver library

Reply Threaded More More options
Print post
Permalink
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 <[hidden email]>,
Stephen Woodbridge <[hidden email]> 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
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev

_______________________________________________
mapserver-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/mapserver-dev