Commit ba1d69bf authored by Christopher Tenter's avatar Christopher Tenter

fix alpha channel of snapshots refs #2506

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20922 383ad7c9-94d9-4d36-a494-682f7c89f535
parent cb430e09
......@@ -2328,6 +2328,27 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
glReadPixels(0,0,w,h,GL_BGRA,GL_UNSIGNED_INT_8_8_8_8_REV,reinterpret_cast<void*>(_image.bits()));
_image = _image.mirrored(false,true);//convert from opengl to qt coordinates
if (_alpha)
{
QRgb backRGBA = qRgba(int(newBack[0] * 255.0f), int(newBack[1] * 255.0f), int(newBack[2] * 255.0f), 0);
// fix alpha channel
for (int i = 0; i < _image.width(); ++i)
{
for (int k = 0; k < _image.height(); ++k)
{
QRgb pix = _image.pixel(i, k);
// snap alpha channel to 255 for pixels different from the background color
if (pix != backRGBA)
pix |= 0xff000000;
_image.setPixel(i, k, pix);
}
}
}
//cleanup
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, prevFbo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment