diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp index e1bd3d11b22..5170c7ab63b 100644 --- a/src/gui/kernel/qopenglwindow.cpp +++ b/src/gui/kernel/qopenglwindow.cpp @@ -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; } /*! diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 44921f68aa2..4cdd8202e99 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -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());