Re: pdfcairo terminal; seams between bars in the colorbox

Dima Kogan <[email protected]> Sat, 17 Jun 2023 21:07:56 -0700
Newsgroups gmane.comp.graphics.gnuplot.devel
Message-ID <[email protected]>
Thanks for merging those. My friend figured out how to get svg to work
in both firefox and chrome, and I'm attaching a patch that does that.
The description is in the patch.

_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
0001-nearest-neighbor-interpolation-for-images-in-svg.patch (text/x-diff, 2 KB)
From 17474a6cc316f4e0a73db0c32b3bace44ad878d1 Mon Sep 17 00:00:00 2001
From: Dima Kogan <[email protected]>
Date: Sat, 17 Jun 2023 19:49:54 -0700
Subject: [PATCH] nearest-neighbor interpolation for images in svg

---
 term/svg.trm | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/term/svg.trm b/term/svg.trm
index 1883a709b..db034867d 100644
--- a/term/svg.trm
+++ b/term/svg.trm
@@ -1876,7 +1876,25 @@ 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' "
+
+            /* This is a hack to enable nearest-neighbor interpolation instead
+               of bilinear or gaussian, or something. When making plots we want
+               to see the discrete pixels. As of today (2023/06) firefox wants
+               "crisp-edges" to make this work, but chrome wants "pixelated".
+               And only that setting works on each browser: using "pixelated"
+               shows blurry images in firefox, for example. According to
+
+                 https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering
+
+               they should both support both settings, but that's not what I
+               observe. Setting both options at the same time doesn't work: you
+               can't have two different "image-rendering" keys. The below is a
+               hack found by Chris McKenzie <[email protected]>. Encoding
+               the other "image-rendering" tag inside a "style" tag makes it
+               work in firefox and in chrome today.
+            */
+            "image-rendering='crisp-edges' style='image-rendering: pixelated' ",
 	    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));
 
-- 
2.37.2