Don't ignore alpha values in grabFramebuffer methods

Returns an ARGB32_Premultiplied image when the framebuffer
is grabbed on a transparent QOpenGLWidget or QOpenGLWindow.

Task-number: QTBUG-55245
Change-Id: I4b7778ecc38275be1ed9fb748c77c7e1f6b65a00
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2016-08-23 13:55:08 +02:00 committed by Tor Arne Vestbø
parent b9b53adb69
commit 3014e2bf01
2 changed files with 6 additions and 3 deletions

View File

@ -511,7 +511,7 @@ GLuint QOpenGLWindow::defaultFramebufferObject() const
extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
/*!
Returns a 32-bit RGB image of the framebuffer.
Returns a copy of the framebuffer.
\note This is a potentially expensive operation because it relies on
glReadPixels() to read back the pixels. This may be slow and can stall the
@ -531,7 +531,9 @@ QImage QOpenGLWindow::grabFramebuffer()
return QImage();
makeCurrent();
QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), false, false);
const bool hasAlpha = format().hasAlpha();
QImage img = qt_gl_read_framebuffer(size() * devicePixelRatio(), hasAlpha, hasAlpha);
img.setDevicePixelRatio(devicePixelRatio());
return img;
}

View File

@ -938,7 +938,8 @@ QImage QOpenGLWidgetPrivate::grabFramebuffer()
q->makeCurrent();
}
QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), false, false);
const bool hasAlpha = q->format().hasAlpha();
QImage res = qt_gl_read_framebuffer(q->size() * q->devicePixelRatioF(), hasAlpha, hasAlpha);
res.setDevicePixelRatio(q->devicePixelRatioF());
// While we give no guarantees of what is going to be left bound, prefer the