SVG output without image smoothing

Dima Kogan <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Message-ID <[email protected]>
Hi.

I'm seeing that currently our svg output produces blurred images. I'm
attaching a patch to (sorta) fix this.

Demo script:

  set terminal svg standalone
  set output "/tmp/tst.svg"
  set view map
  splot [0:10][0:10] '++' using 1:2:($1+$2) with image

The images before and after the patch are attached. Using firefox, you
can see the before-patch image containing smoothed pixels, while the
after-patch image contains pixels with crisp edges, which is what we
want I think.

Unfortunate caveat: apparently firefox and chrome can't agree on what to
call this property. Firefox wants "crisp-edges" to do this, while Chrome
wants "pixelated". So today, this patch will do the right thing on
Firefox, but not on Chrome. Anybody know how to make this work on both
(and the others, I guess)?

I'm on the fence about whether patching gnuplot to work with just one of
the two is better than keeping them both blurry in the same way.

_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
svg-image-crisp-edges.patch (text/x-diff, 681 B)
diff --git a/term/svg.trm b/term/svg.trm
index b2e252f06..d20c6173f 100644
--- a/term/svg.trm
+++ b/term/svg.trm
@@ -1857,7 +1870,7 @@ SVG_image (unsigned m, unsigned n, coordval *image, gpiPoint *corner, t_imagecol
     SVG_PathClose();
 
     /* Map image onto the terminal's coordinate system. */
-    fprintf(gpoutfile, "<image x='%.*f' y='%.*f' width='%.*f' height='%.*f' preserveAspectRatio='none' ",
+    fprintf(gpoutfile, "<image x='%.*f' y='%.*f' width='%.*f' height='%.*f' preserveAspectRatio='none' image-rendering='crisp-edges' ",
 	    PREC, X(corner[0].x), PREC, Y(corner[0].y),
 	    PREC, X(corner[1].x) - X(corner[0].x), PREC, Y(corner[1].y) - Y(corner[0].y));
tst-before.svg (image/svg+xml, 26.2 KB) - not displayed
tst-after.svg (image/svg+xml, 26.2 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.