Re: [gtk-list] An image viewer on the Gnome::Canvas in perl




  Hello,

#  I wrote the following image viewer with the perl Gnome::Canvas module.

  A first question : What version of Gtk-Perl are you using? I have
0.6.123, but I cannot do "use Gnome" with it (don't know why, never
tried it before). I tried 0.7.000 this morning, but then I could not
do "use Gtk::Gdk::ImlibImage". In fact, the test of Gtk::Gdk::-
ImlibImage functionality provided with Gtk-Perl fails too, and
couldn't put it to work (didn't try very hard).

#  In terms of functionality everything except scrolling works quite well.


#  The main work of this pseudo widget is done in the sub view_changed()
#  that does the following series of calls:
    
#      $sim = $img->crop_and_clone($x0,$y0,$cw,$ch);
#      $sim2 = $sim->clone_scaled_image($sw, $sh);
#      $canv_img->get("image")->destroy_image;
#      $canv_img->set("image",$sim2);

#  Where:
#      $img        is the original imlib image
#      $x0, $y0    Are the coordinates in the orig image beeing zoomed in.
#      $cw, $ch    Are the width and the height of the area beeing zoomed in.
#      $sw, $sh    are the scaled width and height.

#  Thus there is a lot of work being done for every scrolling and scaling
                   ^^^^^^^^^^^
                 I have a small image display program, using Gtk-Perl
           (no Gnome). Scrolling is not slow at all (maybe it has to
        do with image size (512x768 is ok) and/or machine (PII/350).
        Zooming is ok too, but I only zoom on limited areas (selected
     with crop_and_clone_image()), and once I have zoomed, I can't
                       scroll out of the zoomed area. 


#  callback action. If the image had a parameter "-crop" indicating the
#  rectangle of the original image currently being viewed, then there
#  could be more intelligent scrolling being done inside the canvas image
#  widget code, but as it is now, I don't think I can make it any faster.
#  But I would be happy if you could prove me wrong.

#  I would also be very thankful if someone could make this pseudo widget
#  into a real widget, or at least point me to documentation of how to
#  do this in perl.
  
    What do you mean by "real widget" ? (I have Havoc Pennington's
book around, but I didn't get at it seriously). One possibility is to
do a "class" (perl package) for an "image viewer" object which you can
then add to GtkBox'es. Would you like to have a look at my code (which
does this, in perl)? Warning : I am not sure if I did things right
(but, in perl, there's more than one way to do it, of course). 

  I hope I can get "use Gnome" to work, so I can try your app.

  Cheers,

  Etienne



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