Gtk::Gdk::Pixmap from PDL



Hi again!

I played around a little bit more and found out the following: it works if
I load an image directly from an xpm file this way:

----------8<----------
      my $style = Gtk::Widget->get_default_style;
      my ($gdk_pixmap,$gdk_mask) = Gtk::Gdk::Pixmap->create_from_xpm(
        $form->{'ovis_main'}->window,
	$style->bg('normal'),
	"pixmaps/test.xpm"
      );
	
      $form->{'pixmap1'}->set($gdk_pixmap,$gdk_mask);
---------->8----------

But taking it from a piddle crashes:

----------8<----------
      my $image = rpic("$filename");
      $image %= 256; $image->byte;

      my @i = $image->dims;
      if ($#i==2) { splice(@i,0,1); }        # remove color dimension 
      if ($#i!=2) {}                         # ??? error
      
      my ($width,$height) = @i;
      
      my ($gdk_pixmap,$gdk_mask) = Gtk::Gdk::Pixmap->create_from_data(
        $form->{'ovis_main'}->window,
        ${$image->get_dataref},
	$width,$height,
	8,
	Gtk::Gdk::Color->parse_color('white'),
	Gtk::Gdk::Color->parse_color('black')
      );
---------->8----------

This results in a 

Gdk-ERROR **: BadValue (integer parameter out of range for operation)
  serial 2297 error_code 2 request_code 53 minor_code 0
Gdk-ERROR **: BadDrawable (invalid Pixmap or Window parameter)
  serial 2299 error_code 9 request_code 72 minor_code 0

By the way: the get_dataref function seems to be undocumented in PDL...?

Cheers,
Robert
-- 
 +----------------------------------------------------------+
  Robert Schwebel, Luedemannstrasse 25, 24114 Kiel, Germany 
    Public Observatory Rothwesten  (near Kassel, Germany)   
      Phone: +49-431-6794138, email: robert@schwebel.de     



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