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:
parent
b9b53adb69
commit
3014e2bf01
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user