diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-31 18:12:49 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-10-31 18:12:53 +0100 |
commit | a535703add6bf29878845cb270997514489cfc16 (patch) | |
tree | 6816c8749c0dde59cc936cdc274307b0561bac27 /src/GtkGif.cpp | |
parent | 687796532d80fc6a0ae8327eec8f901002bdc0dd (diff) |
Start with images/gif, resize chat input
Diffstat (limited to 'src/GtkGif.cpp')
-rw-r--r-- | src/GtkGif.cpp | 31 |
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 |