]> git.lyx.org Git - lyx.git/commitdiff
Use bilinear filtering when resizing graphics
authorGuillaume Munch <gm@lyx.org>
Sat, 30 Apr 2016 18:56:57 +0000 (19:56 +0100)
committerGuillaume Munch <gm@lyx.org>
Fri, 20 May 2016 20:19:31 +0000 (21:19 +0100)
This is used when scaling graphics previews. It is also used on a rare occasion
to scale instant previews when the user's configuration mixes low-dpi and
high-dpi monitors (#10114).

src/frontends/qt4/GuiImage.cpp
src/frontends/qt4/GuiPainter.cpp

index eb5124fcadae65017e39fa3a51100bdc10b644fd..08259ecd92b43a6e69e339ad2869b5d203adc3e8 100644 (file)
@@ -207,7 +207,8 @@ bool GuiImage::scale(Params const & params)
 
        QMatrix m;
        m.scale(scale, scale);
-       transformed_ = image.transformed(m);
+       // Bilinear filtering is used to scale graphics preview
+       transformed_ = image.transformed(m, Qt::SmoothTransformation);
        return true;
 }
 
index b67441b9b17d26cacc21f5d4cf22d0f5526c33b6..495a11a8a6f036892bb9d088364bb06e228e0583 100644 (file)
@@ -317,7 +317,13 @@ void GuiPainter::image(int x, int y, int w, int h, graphics::Image const & i)
        QImage const image = qlimage.image();
        QRectF const drect = QRectF(x, y, w, h);
        QRectF const srect = QRectF(0, 0, image.width(), image.height());
+       // Bilinear filtering is needed on a rare occasion for instant previews when
+       // the user's configuration mixes low-dpi and high-dpi monitors (#10114).
+       // This filter is optimised by qt on pixel-aligned images, so this does not
+       // affect performances in other cases.
+       setRenderHint(SmoothPixmapTransform);
        drawImage(drect, image, srect);
+       setRenderHint(SmoothPixmapTransform, false);
 }