diff --git a/examples/opengl/grabber/mainwindow.cpp b/examples/opengl/grabber/mainwindow.cpp index 9f31733856f..9f82ee10bac 100644 --- a/examples/opengl/grabber/mainwindow.cpp +++ b/examples/opengl/grabber/mainwindow.cpp @@ -175,7 +175,7 @@ QSlider *MainWindow::createSlider(const char *changedSignal, void MainWindow::setPixmap(const QPixmap &pixmap) { pixmapLabel->setPixmap(pixmap); - QSize size = pixmap.size(); + QSize size = pixmap.size() / pixmap.devicePixelRatio(); if (size - QSize(1, 0) == pixmapLabelArea->maximumViewportSize()) size -= QSize(1, 0); pixmapLabel->resize(size); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index def04706221..72c6e035d93 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4090,11 +4090,12 @@ QImage QGLWidget::grabFrameBuffer(bool withAlpha) { makeCurrent(); QImage res; - int w = width(); - int h = height(); + qreal pixelRatio = devicePixelRatio(); + int w = pixelRatio * width(); + int h = pixelRatio * height(); if (format().rgba()) res = qt_gl_read_frame_buffer(QSize(w, h), format().alpha(), withAlpha); - + res.setDevicePixelRatio(pixelRatio); return res; }