aboutsummaryrefslogtreecommitdiff
path: root/src/GtkGif.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GtkGif.cpp')
-rw-r--r--src/GtkGif.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/GtkGif.cpp b/src/GtkGif.cpp
new file mode 100644
index 0000000..1da48a8
--- /dev/null
+++ b/src/GtkGif.cpp
@@ -0,0 +1,31 @@
+#include "../include/GtkGif.hpp"
+
+namespace dchat
+{
+ GtkGif::GtkGif(StringView fileContent) :
+ Gif(fileContent)
+ {
+ //signal_draw().connect(sigc::mem_fun(*this, &GtkGif::updateContent));
+ set_app_paintable(true);
+ }
+
+ bool GtkGif::createTexture(int width, int height)
+ {
+ surface = Cairo::ImageSurface::create(Cairo::Format::FORMAT_ARGB32, width, height);
+ return true;
+ }
+
+ void GtkGif::updateTexture(void *textureData)
+ {
+ unsigned char *pixels = surface->get_data();
+ memcpy(pixels, textureData, surface->get_stride() * surface->get_height());
+ }
+
+ bool GtkGif::on_draw(const Cairo::RefPtr<Cairo::Context> &cairo)
+ {
+ update();
+ cairo->set_source(surface, 0.0, 0.0);
+ cairo->fill();
+ return true;
+ }
+} \ No newline at end of file