From 1113ec294d0f92f4961d3f102ef7a702a765cfe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 27 Apr 2010 10:34:43 +0200 Subject: Fixed QGLWidget::grabFrameBuffer() to honor the 'withAlpha' value. Task-number: QTBUG-7545 Reviewed-by: Kim --- src/opengl/qgl.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index ca898c7..c294e4f 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1534,7 +1534,14 @@ static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, boo uint *q = (uint*)img.scanLine(y); for (int x=0; x < w; ++x) { const uint pixel = *q; - *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); + if (alpha_format && include_alpha) { + *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) + | (pixel & 0xff00ff00); + } else { + *q = 0xff000000 | ((pixel << 16) & 0xff0000) + | ((pixel >> 16) & 0xff) | (pixel & 0x00ff00); + } + q++; } } @@ -1545,7 +1552,8 @@ static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, boo QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) { - QImage img(size, alpha_format ? QImage::Format_ARGB32 : QImage::Format_RGB32); + QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32 + : QImage::Format_RGB32); int w = size.width(); int h = size.height(); glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); -- cgit v0.12