From ff65bec92ce05b34a756b852eda60ca68e65dc9f Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 22 Jul 2020 19:10:09 +0200 Subject: [PATCH] Introduce a GLTexture::toImage helper class --- libkwineffects/kwingltexture.cpp | 7 +++++++ libkwineffects/kwingltexture.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/libkwineffects/kwingltexture.cpp b/libkwineffects/kwingltexture.cpp index 467fbbfb3d..87664ada20 100644 --- a/libkwineffects/kwingltexture.cpp +++ b/libkwineffects/kwingltexture.cpp @@ -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 diff --git a/libkwineffects/kwingltexture.h b/libkwineffects/kwingltexture.h index 09474466a4..4620362a6c 100644 --- a/libkwineffects/kwingltexture.h +++ b/libkwineffects/kwingltexture.h @@ -113,6 +113,8 @@ public: GLenum filter() const; GLenum internalFormat() const; + QImage toImage() const; + /** @short * Make the texture fully transparent */