From 4af9674f170d70503ca31fe0a13ae3247705ea54 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 16 Aug 2021 12:28:40 +0300 Subject: [PATCH] Revert "screenshot: Reuse GLTexture::toImage" This reverts commit ac16bef409a758fa2071c552bc36c0aa6e31af7f. It causes crashes and color channels seem to be swapped. GLTexture::toImage() needs more work before it can be used in the screenshot effect, or maybe dropped. --- src/effects/screenshot/screenshot.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/effects/screenshot/screenshot.cpp b/src/effects/screenshot/screenshot.cpp index 3357172e5a..20933d7cfc 100644 --- a/src/effects/screenshot/screenshot.cpp +++ b/src/effects/screenshot/screenshot.cpp @@ -361,10 +361,15 @@ QImage ScreenShotEffect::blitScreenshot(const QRect &geometry, qreal devicePixel const QSize nativeSize = geometry.size() * devicePixelRatio; if (GLRenderTarget::blitSupported() && !GLPlatform::instance()->isGLES()) { + image = QImage(nativeSize.width(), nativeSize.height(), QImage::Format_ARGB32); GLTexture texture(GL_RGBA8, nativeSize.width(), nativeSize.height()); GLRenderTarget target(texture); target.blitFromFramebuffer(geometry); - image = texture.toImage(); + // copy content from framebuffer into image + texture.bind(); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, + static_cast(image.bits())); + texture.unbind(); } else { image = QImage(nativeSize.width(), nativeSize.height(), QImage::Format_ARGB32); glReadPixels(0, 0, nativeSize.width(), nativeSize.height(), GL_RGBA,