From e3bb0b1c453ab7b7ac0efa8a2f9ba5e3e7c7a7d4 Mon Sep 17 00:00:00 2001 From: daleclack Date: Sun, 26 Dec 2021 13:40:09 +0800 Subject: [PATCH] Update gtk119 --- Gtkmm3/gtk119_imageviewer2/src/MyImage.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Gtkmm3/gtk119_imageviewer2/src/MyImage.cc b/Gtkmm3/gtk119_imageviewer2/src/MyImage.cc index 30dd1de..cfcab9e 100644 --- a/Gtkmm3/gtk119_imageviewer2/src/MyImage.cc +++ b/Gtkmm3/gtk119_imageviewer2/src/MyImage.cc @@ -16,12 +16,14 @@ bool MyImage::on_draw(const Cairo::RefPtr &cr){ int width = image->get_width(); int height = image->get_height(); + //Set the default size for drawing area set_size_request(width,height); // Draw the image in the middle of the drawing area, or (if the image is // larger than the drawing area) draw the middle part of the image. Gdk::Cairo::set_source_pixbuf(cr, image, (width - image->get_width())/2, (height - image->get_height())/2); + cr->paint(); return true; @@ -29,6 +31,10 @@ bool MyImage::on_draw(const Cairo::RefPtr &cr){ void MyImage::set_pixbuf(const Glib::RefPtr &pixbuf) { + if(image){ + image.reset(); + } + image = pixbuf; //ReDraw the draw area