Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3868 closed defect (fixed)

Grid of thin lines in polygon symbol fills

Reported by: havatv Owned by: tbonfort
Priority: normal Milestone: 6.2 release
Component: Renderer API Version: svn-trunk (development)
Severity: normal Keywords: polygon fill, gaps, rendering
Cc: havatv, sdlime

Description

In maprendering.c, when rendering polygon fills using symbols, 1 is added to the symbol size in both the x and the y direction for scaled symbols:

652	            if(s.scale != 1) {
653	               pw = MS_NINT(symbol->sizex * s.scale + s.gap)+1;
654	               ph = MS_NINT(symbol->sizey * s.scale + s.gap)+1;
655	            } else {
656	               pw = symbol->sizex + s.gap;
657	               ph = symbol->sizey + s.gap;
658	            }

This produced a grid of thin lines of "background" colour in the polygon fill at the symbol boundaries (both for GD and AGG).

I am not that familiar with the code, but since the GD renderer does not do anti-aliasing, eliminating the one unit addition should make it easier to get good polygon fill rendering with GD.

I have tried to remove the one unit addition, and if I am careful with the SIZE, the result looks better (both for GD and AGG). It does not seem to produce worse looking results for non-optimal SIZEs. But it might of course have other unwanted side effect.

Attachments (8)

polyfill_whitespace600.png (43.2 KB ) - added by havatv 13 years ago.
polyfill_whitespace600_patched.png (40.7 KB ) - added by havatv 13 years ago.
patched version
polyfill_whitespace600.gif (35.0 KB ) - added by havatv 13 years ago.
gif
polyfill_whitespace600_patched.gif (31.0 KB ) - added by havatv 13 years ago.
gif patched version
polyfill_whitespace_ellipse600.png (36.8 KB ) - added by havatv 13 years ago.
polyfill_whitespace_ellipse600_patched.png (35.7 KB ) - added by havatv 13 years ago.
patched version (ellipse)
polyfill_whitespace_ellipse600.gif (24.1 KB ) - added by havatv 13 years ago.
gif (ellipse)
polyfill_whitespace_ellipse600_patched.gif (23.5 KB ) - added by havatv 13 years ago.
gif patched versoin (ellipse)

Download all attachments as: .zip

Change History (14)

comment:1 by havatv, 13 years ago

Milestone: 6.0 release6.0.1 release

Some more on this one.

I have done the simple fix that I suggested. Here is the diff (6.0.0 branch, but probably the same in trunk):

svn diff mapserver/maprendering.c
Index: mapserver/maprendering.c
===================================================================
--- mapserver/maprendering.c	(revisjon 11726)
+++ mapserver/maprendering.c	(arbeidskopi)
@@ -488,8 +488,8 @@
                   int pw,ph;
                   imageObj* tile=NULL;
                   if(s.scale != 1) {
-                     pw = MS_NINT(symbol->sizex * s.scale)+1;
-                     ph = MS_NINT(symbol->sizey * s.scale)+1;
+                     pw = MS_NINT(symbol->sizex * s.scale);
+                     ph = MS_NINT(symbol->sizey * s.scale);
                   } else {
                      pw = symbol->sizex;
                      ph = symbol->sizey;
@@ -650,8 +650,8 @@
             }
 
             if(s.scale != 1) {
-               pw = MS_NINT(symbol->sizex * s.scale + s.gap)+1;
-               ph = MS_NINT(symbol->sizey * s.scale + s.gap)+1;
+               pw = MS_NINT(symbol->sizex * s.scale + s.gap);
+               ph = MS_NINT(symbol->sizey * s.scale + s.gap);
             } else {
                pw = symbol->sizex + s.gap;
                ph = symbol->sizey + s.gap;

I attach images that show the change in behaviour.

by havatv, 13 years ago

Attachment: polyfill_whitespace600.png added

by havatv, 13 years ago

patched version

by havatv, 13 years ago

Attachment: polyfill_whitespace600.gif added

gif

by havatv, 13 years ago

gif patched version

by havatv, 13 years ago

patched version (ellipse)

by havatv, 13 years ago

gif (ellipse)

by havatv, 13 years ago

gif patched versoin (ellipse)

comment:2 by havatv, 13 years ago

The attachments show the effects of the patch for vector symbol fill and ellipse symbol fill for gif (GD) and png (AGG).

comment:3 by havatv, 13 years ago

Keywords: rendering added; gd removed
Milestone: 6.0.1 release6.2 release

comment:4 by havatv, 13 years ago

Cc: sdlime added

It would have been very nice to get some feedback on this one.

Could somebody explain why the extra pixel is added to the size in the current code, and why it would be a problem to remove it.

If there is no problem, I hope that the patch can be applied, as current behaviour is a showstopper for many "advanced" area fill symbols of type vector.

comment:5 by tbonfort, 13 years ago

Resolution: fixed
Status: newclosed

fixed in r12707.

the reason this pixel was added was to account for the antialiasing of vectors which bleeds out of the strict bounding box given by the symbol's size. The workaround in that case will be to add a sufficient GAP to account for this.

comment:6 by havatv, 13 years ago

The trunk symbol construction document has been updated (r12724).

Note: See TracTickets for help on using tickets.