Re: Display Portions of an Image



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Howdy,

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} ) {
        $self->{icon}->set_from_pixbuf($image_to_display);
    }
    else {
        $self->{icon} = Gtk2::Image->new_from_pixbuf($display_image);
        $self->{widget}->add($self->{icon});  # Widget is a button
    }
    $self->{widget}->queue_draw;

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


- -- 
 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?"
 http://openthought.net       | Schroeder: "The joy is in the playing."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE/JY3zR5UKaDAjAG4RAlJdAKCxfBbtzo3/452wOtDLxVRwKqRExQCffgrN
MT7Y2W7D8S3Ri+9D9z9dTQI=
=nqXn
-----END PGP SIGNATURE-----



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