Fix hidpi support for opengl window grabbing

Now set the QImage devicePixelRatio so the content is correct on all
screens.

Task-number: QTBUG-53795
Change-Id: Ic92eee98f691ebb1e0212498c1ae13ede74bca93
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Filipe Azevedo 2016-12-13 16:02:23 +01:00
parent 944bf6867f
commit 07bd5a90a3
2 changed files with 4 additions and 1 deletions

View File

@ -528,7 +528,9 @@ QImage QOpenGLWindow::grabFramebuffer()
return QImage();
makeCurrent();
return qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false);
QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false);
img.setDevicePixelRatio(devicePixelRatio());
return img;
}
/*!

View File

@ -381,6 +381,7 @@ static bool fuzzyComparePixels(const QRgb testPixel, const QRgb refPixel, const
static void fuzzyCompareImages(const QImage &testImage, const QImage &referenceImage, const char* file, int line)
{
QCOMPARE(testImage.devicePixelRatio(), referenceImage.devicePixelRatio());
QCOMPARE(testImage.width(), referenceImage.width());
QCOMPARE(testImage.height(), referenceImage.height());