summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond.kjernasen@nokia.com>2010-04-27 08:34:43 (GMT)
committerTrond Kjernåsen <trond.kjernasen@nokia.com>2010-04-27 08:34:43 (GMT)
commit1113ec294d0f92f4961d3f102ef7a702a765cfe3 (patch)
treecde71cf5379ab3a31ba5d876df91b4a1dc71ad21
parentb5b096996de656dc44723b02826d892291173797 (diff)
downloadQt-1113ec294d0f92f4961d3f102ef7a702a765cfe3.zip
Qt-1113ec294d0f92f4961d3f102ef7a702a765cfe3.tar.gz
Qt-1113ec294d0f92f4961d3f102ef7a702a765cfe3.tar.bz2
Fixed QGLWidget::grabFrameBuffer() to honor the 'withAlpha' value.
Task-number: QTBUG-7545 Reviewed-by: Kim
-rw-r--r--src/opengl/qgl.cpp12
1 files 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());