Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-10-26 Thread Les Trol
I'm implementing a spec in which an image is displayed in a Gtk2::Textview. Simple enough to do, but the spec requires optional extras, such as displaying padding around the image and detecting clicks on it.   Taking one problem at a time:   1. Sometimes the image must be displayed its origina

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-10-26 Thread Dov Grobgeld
Try creating a new (empty) image of the required size and then use cairo to fill it with the desired contents. The following link may help you (though it is in C and not perl, but the API is the same): https://gist.github.com/bert/985903 Regards, Dov On Thu, Oct 26, 2017 at 11:18 AM, Les Trol

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-10-27 Thread Les Trol
  Try creating a new (empty) image of the required size and then use cairo to fill it with the desired contents. The following link may help you (though it is in C and not perl, but the API is the same):   https://gist.github.com/bert/985903   I don't know any C, but as far as I can

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-01 Thread Les Trol
Ok, second intractable problem:   2. The spec also wants to detect mouse clicks on the displayed image. With this I've barely made any progress at all.   I tried some obvious things. However, Gtk2::TextIter->get_pixbuf() only detects mouse motion of the left half of the image (for no obvious r

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-01 Thread Eric Cashon via gtk-perl-list
Hi Les, See if this works better for the cat. Eric #!/usr/bin/perl package scaleme; use strict; use diagnostics; use warnings; use Gtk2 '-init'; use Glib qw(TRUE FALSE); # Display this image my $path = 'cat.png'; # Open a Gtk2 window with a Gtk2::TextView my $window = Gtk2::Windo

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-01 Thread Eric Cashon via gtk-perl-list
Hi Les, If you put the pixbuf in an image widget and the image widget in an event box then you can get your mouse clicks from the pixbuf. The event box can then be added to the textview widget. Eric ___ gtk-perl-list mailing list gtk-perl-lis

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-02 Thread Les Trol
>The event box can then be added to the textview widget.   How, exactly?   We have Gtk2::TextBuffer->insert for inserting text, Gtk2::TextBuffer->insert_pixbuf for inserting pixbufs, but no equivalent method for inserting an event box (something like Gtk2::TextBuffer->insert_event_box ).   Pe

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-02 Thread Eric Cashon via gtk-perl-list
Try inserting a widget into the textview and capture the clicks on the widget. In this case, an event box with an image widget and pixbuf. Eric #!/usr/bin/perl package scaleme; use strict; use diagnostics; use warnings; use Gtk2 '-init'; use Glib qw(TRUE FALSE); # Display this image my

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-02 Thread Jeremy Volkening
On Wed, Nov 01, 2017 at 08:10:29PM +0100, Les Trol wrote: Ok, second intractable problem: 2. The spec also wants to detect mouse clicks on the displayed image. With this I've barely made any progress at all. I tried some obvious things. However, Gtk2::TextIter->get_pixbuf() only detects mouse m

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-03 Thread Les Trol
Two down, one to go!   3. The spec wants the image to be displayable on the left or right of the textview, with any accompanying text at the top, middle or bottom of the image.   I used Gtk2::TextTags with the 'justification' and 'rise' properties set. 'justification' works just fine when there

Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale

2017-11-03 Thread Eric Cashon via gtk-perl-list
It sounds like some tricky layout features for the textview. Maybe wrapping text around images? Not sure how to go about doing this. One thing to try is putting another textview in there with the image. Then you can size it to the image height and could resize it based on the overall window