diff options
-rw-r--r-- | src/opengl/qgl.cpp | 12 |
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()); |