Introduce a GLTexture::toImage helper class

master
Aleix Pol 2020-07-22 19:10:09 +02:00
parent 1ef90d9c90
commit ff65bec92c
2 changed files with 9 additions and 0 deletions

View File

@ -683,4 +683,11 @@ bool GLTexture::supportsFormatRG()
return GLTexturePrivate::s_supportsTextureFormatRG;
}
QImage GLTexture::toImage() const
{
QImage ret(size(), QImage::Format_RGBA8888_Premultiplied);
glGetTextureImage(texture(), 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ret.sizeInBytes(), ret.bits());
return ret;
}
} // namespace KWin

View File

@ -113,6 +113,8 @@ public:
GLenum filter() const;
GLenum internalFormat() const;
QImage toImage() const;
/** @short
* Make the texture fully transparent
*/