Gui: fix screentshot
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
# include <QFile>
|
||||
# include <QImage>
|
||||
# include <QImageWriter>
|
||||
# include <QPainter>
|
||||
#endif
|
||||
|
||||
#if !defined(FC_OS_MACOSX)
|
||||
@@ -405,7 +406,7 @@ void SoQtOffscreenRenderer::init(const SbViewportRegion & vpr,
|
||||
else {
|
||||
this->renderaction = new SoGLRenderAction(vpr);
|
||||
this->renderaction->setCacheContext(SoGLCacheContextElement::getUniqueCacheContext());
|
||||
this->renderaction->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_BLEND);
|
||||
this->renderaction->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND);
|
||||
}
|
||||
|
||||
this->didallocation = glrenderaction ? false : true;
|
||||
@@ -818,9 +819,6 @@ SoQtOffscreenRenderer::writeToImage (QImage& img) const
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (PRIVATE(this)->backgroundcolor[3] == 1.0) {
|
||||
img = img.convertToFormat(QImage::Format_RGB32);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -1608,6 +1608,7 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI
|
||||
renderer.setViewportRegion(vp);
|
||||
renderer.getGLRenderAction()->setSmoothing(true);
|
||||
renderer.getGLRenderAction()->setNumPasses(s);
|
||||
renderer.getGLRenderAction()->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND);
|
||||
if (bgColor.isValid())
|
||||
renderer.setBackgroundColor(SbColor(bgColor.redF(), bgColor.greenF(), bgColor.blueF()));
|
||||
if (!renderer.render(root))
|
||||
@@ -1616,6 +1617,15 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI
|
||||
renderer.writeToImage(img);
|
||||
root->unref();
|
||||
}
|
||||
|
||||
if (!bgColor.isValid() || bgColor.alphaF() == 1.0) {
|
||||
QImage image(img.width(), img.height(), QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
painter.fillRect(image.rect(), Qt::black);
|
||||
painter.drawImage(0, 0, img);
|
||||
painter.end();
|
||||
img = image;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
root->unref();
|
||||
@@ -2048,6 +2058,13 @@ QImage View3DInventorViewer::grabFramebuffer()
|
||||
renderToFramebuffer(&fbo);
|
||||
|
||||
res = fbo.toImage(false);
|
||||
|
||||
QImage image(res.width(), res.height(), QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
painter.fillRect(image.rect(),Qt::black);
|
||||
painter.drawImage(0, 0, res);
|
||||
painter.end();
|
||||
res = image;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2111,8 +2128,14 @@ void View3DInventorViewer::imageFromFramebuffer(int width, int height, int sampl
|
||||
bits++;
|
||||
}
|
||||
}
|
||||
} else if (alpha == 255)
|
||||
img = img.convertToFormat(QImage::Format_RGB32);
|
||||
} else if (alpha == 255) {
|
||||
QImage image(img.width(), img.height(), QImage::Format_RGB32);
|
||||
QPainter painter(&image);
|
||||
painter.fillRect(image.rect(),Qt::black);
|
||||
painter.drawImage(0, 0, img);
|
||||
painter.end();
|
||||
img = image;
|
||||
}
|
||||
}
|
||||
|
||||
void View3DInventorViewer::renderToFramebuffer(QtGLFramebufferObject* fbo)
|
||||
|
||||
@@ -617,15 +617,6 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action)
|
||||
// material override with transparncy won't work.
|
||||
mb.sendFirst();
|
||||
|
||||
if(SoShapeStyleElement::get(state)->getFlags()
|
||||
& (SoShapeStyleElement::TRANSP_TEXTURE|SoShapeStyleElement::TRANSP_MATERIAL))
|
||||
{
|
||||
// For some reason, there is an inconsistence in blending state between
|
||||
// OpenGL and Coin, especially when doing offscreen rendering.
|
||||
if(!glIsEnabled(GL_BLEND))
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
|
||||
// When setting transparency shouldGLRender() handles the rendering and returns false.
|
||||
// Therefore generatePrimitives() needs to be re-implemented to handle the materials
|
||||
// correctly.
|
||||
|
||||
Reference in New Issue
Block a user