mangled binary data



i'm having immense trouble getting progressive pixbuf loading to work.  i'm
not quite sure where the problem is, but i suspect it has to do with
ASCII<->UTF-8 mangling of data read from a file handle and sent to a
subroutine.


check out gtk2-perl-xs/Gtk2/gtk-demo/images.pl, where you'll find this code
(excerpted here for readability):


      use bytes;
      my $buf;
      my $bytes_read = sysread ($image_stream, $buf, 256);

      ...

      eval { use bytes; $pixbuf_loader->write ($buf); };


this looks innocent enough, but no matter what i do, i can't get the
Gtk2::PixbufLoader to read more than one stripe of data out of the known-valid
image.  by adding the 'use bytes' pragma i'm forcing the $buf to be in bytes
rather than utf8, which functions correctly (according to Devel::Peek) but
doesn't seem to help.  i get different results with different images; in
particular, a known-good ppm loads with what looks like a 70-or-80-pixel
offset and color shift (it looks blue instead of red); and the background.jpg
image in the same directory either doesn't show at all or only loads
partially.

the XS for gdk_pixbuf_loader_write (in
gtk2-perl-xs/Gtk2/xs/GdkPixbufLoader.xs) shows that i've tried lots of things,
but a direct SvPVX to get the raw string pointer doesn't behave any
differently than the default SvPV_nolen provided by the typemap for guchar*.



help!  does anybody know what's wrong?


(if the images aren't in CVS, you'll find them in gtk+-2.x.x/demos/gtk-demo)


-- 
muppet <scott at asofyet dot org>





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