Well, anti-aliased maps look much better and are basically the way to go. But 
in some corner cases it would be great to be able to turn this feature off. 
Cairo provides a single switch to do that and a patch that enables control over 
that from within MapServer can be simple and straight forward. With a little 
more effort this can be extended to switch between all possible 
CAIRO_ANTIALIAS_* values. So IMHO integrating this option for the Cairo 
renderer seems to be a good idea. For the AGG renderer it requires more work to 
make this runtime controllable. 

@Richard: The difference between both renderers is impressive. Since you are 
using this with much more complex maps can you give some feedback which one 
which one looks "better" (with tuning applied) and how usable the result is?

Regards, Andreas

-----Ursprüngliche Nachricht-----
Von: Steve Lime <[email protected]> 
Gesendet: Mittwoch, 19. Mai 2021 18:24
An: Eichner, Andreas - SID <[email protected]>
Cc: Richard Greenwood <[email protected]>; mapserver 
<[email protected]>
Betreff: Re: [mapserver-users] anti-aliasing (was differing image size with 
different mapserver versions)

Worth adding to main?

On Wed, May 19, 2021 at 10:15 AM Eichner, Andreas - SID 
<[email protected] <mailto:[email protected]> > wrote:


        If you want to give Cairo a try, you could modify mapcairo.c like this:
        
        diff --git a/mapcairo.c b/mapcairo.c
        index 0f4cc094..d28947d6 100644
        --- a/mapcairo.c
        +++ b/mapcairo.c
        @@ -517,6 +517,12 @@ imageObj* createImageCairo(int width, int height, 
outputFormatObj *format,colorO
        
             cairo_set_line_cap (r->cr,CAIRO_LINE_CAP_ROUND);
             cairo_set_line_join(r->cr,CAIRO_LINE_JOIN_ROUND);
        +    {
        +        const char* antialias = msGetOutputFormatOption(format, 
"ANTIALIAS", "TRUE");
        +        if (EQUAL(antialias, "OFF") || EQUAL(antialias, "FALSE") || 
EQUAL(antialias, "0")) {
        +            cairo_set_antialias(r->cr, CAIRO_ANTIALIAS_NONE);
        +        }
        +    }
             image->img.plugin = (void*)r;
           } else {
             msSetError(MS_RENDERERERR, "Cannot create cairo image of size 
%dx%d.",
        
        This adds a FORMATOPTION "ANTIALIAS" to the CAIRO/*-Drivers that 
defaults to TRUE. But when explicitly set to 0/OFF/FALSE it calls 
cairo_set_antialias() to disable it. The raster buffer created by the CAIRO 
renderer is passed to the PNG writer which enables COMPRESSION, PALETTE_FORCE, 
QUANTIZE_FORCE. So you can combine it:
        
         OUTPUTFORMAT
           NAME "cairopng"
           DRIVER CAIRO/PNG
           MIMETYPE "image/png"
           IMAGEMODE RGB
           EXTENSION "png"
           FORMATOPTION "ANTIALIAS=FALSE"
           FORMATOPTION "QUANTIZE_FORCE=ON"
           FORMATOPTION "QUANTIZE_COLORS=256"
           FORMATOPTION "COMPRESSION=9"
         END
        
        I used the msautotest/renderers/line_simple.map example to test and 
that crushed the resulting png from 5920 bytes down to 947 bytes. 
        
        HTH, Andreas
        
        

_______________________________________________
mapserver-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to