Re: Display Portions of an Image

Hash: SHA1


if the GtkImage you are using is set to use a GdkPixbuf for internal 
storage, you should be able to ask the GtkImage for the pixbuf it uses, 
and draw onto that.  then you have to figure out how to get the widget 
to redraw itself (used to be gtk_widget_queue_draw, but i'm not sure 

I'm almost there!  Using Gavin's explanation of copy_area, and Scott's
suggestion of writing on the images existing pixbuf, it does work.  Sort of.

I'm using this code:

    if ( exists $self->{icon} ) {
    else {
        $self->{icon} = Gtk2::Image->new_from_pixbuf($display_image);
        $self->{widget}->add($self->{icon});  # Widget is a button

I've found that the image, using the above code, will not redraw itself.  That
was incredibly frustrating, until I decided to output some debug information to
try and figure out the problem.  As soon as I did so, it worked fine.

That is, if I simply add to the bottom of the above code:

  print "Something is fishy";

The image happily redraws itself.

Does anyone have any suggestions on a better way to get this thing to redraw,
without needing to output anything?  FWIW, outputting text only fixes the
problem when I output to STDOUT.  Using warn to print to STDERR will not fix
it, the image doesn't get redrawn in that case.

Any thoughts would be great, thanks!

- -- 
 Eric Andreychek              | Lucy: "What happens if you practice the
 Eric Conspiracy Secret Labs  |  piano for 20 years and then end up not
 eric openthought net         |  being rich and famous?"       | Schroeder: "The joy is in the playing."
Version: GnuPG v1.0.7 (GNU/Linux)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]