From a535703add6bf29878845cb270997514489cfc16 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 31 Oct 2018 18:12:49 +0100 Subject: Start with images/gif, resize chat input --- src/GtkGif.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/GtkGif.cpp (limited to 'src/GtkGif.cpp') 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) + { + update(); + cairo->set_source(surface, 0.0, 0.0); + cairo->fill(); + return true; + } +} \ No newline at end of file -- cgit v1.2.3