From 78ac86abd22bb4d4a84e9f7c85a71e3be186ff57 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Sat, 11 Jan 2020 15:20:24 +0800 Subject: [PATCH] Gui: fix screenshot with opaque background --- src/Gui/SoFCOffscreenRenderer.cpp | 3 +++ src/Gui/View3DInventorViewer.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Gui/SoFCOffscreenRenderer.cpp b/src/Gui/SoFCOffscreenRenderer.cpp index b89bcd7b51..4b6524124a 100644 --- a/src/Gui/SoFCOffscreenRenderer.cpp +++ b/src/Gui/SoFCOffscreenRenderer.cpp @@ -818,6 +818,9 @@ SoQtOffscreenRenderer::writeToImage (QImage& img) const } } } + else if (PRIVATE(this)->backgroundcolor[3] == 1.0) { + img = img.convertToFormat(QImage::Format_RGB32); + } } /*! diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 13a9b46312..ed57bfc920 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2111,7 +2111,8 @@ void View3DInventorViewer::imageFromFramebuffer(int width, int height, int sampl bits++; } } - } + } else if (alpha == 255) + img = img.convertToFormat(QImage::Format_RGB32); } void View3DInventorViewer::renderToFramebuffer(QtGLFramebufferObject* fbo)