Re: Gtk2::Gdk::Pixbuf on win32




On Mar 2, 2008, at 11:07 PM, T.J. Ferraro wrote:

rn any case, I figured I would give it a try right now. However, when I
use Gtk2::Image and pack it all I get is a small box with a red X.
Calling either get_pixbuf or get_image, gives me either:

Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type ==
GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'

Gtk-CRITICAL **: gtk_image_get_image: assertion `image->storage_type ==
GTK_IMAGE_IMAGE || image->storage_type == GTK_IMAGE_EMPTY'

That's most likely because the image failed to load.


Any other suggestions? Thanks.

Are you sure that your gtk+ (actually, gdk-pixbuf) supports BMP? This works in a nice, comfy linux shell, so you'll have to experiment with quoting on your rickety windows shells:

$ perl -MGtk2 -e 'printf " %5s %s\n", $_->{name}, $_->{description} foreach Gtk2::Gdk::Pixbuf->get_formats'
   ani   The ANI image format
   bmp   The BMP image format
   gif   The GIF image format
   ico   The ICO image format
  jpeg   The JPEG image format
   pcx   The PCX image format
   png   The PNG image format
   pnm   The PNM/PBM/PGM/PPM image format family
   ras   The Sun raster image format
   tga   The Targa image format
  tiff   The TIFF image format
  wbmp   The WBMP image format
   xbm   The XBM image format
   xpm   The XPM image format
   svg   Scalable Vector Graphics



In your earlier message, you gave the error message:

Couldn't recognize the image file format for file 'image.bmp' at imagetest.pl line 13.

This comes from gtk+/gdk-pixbuf/gdk-pixbuf-io.c around line 728 (line numbers may vary by version), in the function _gdk_pixbuf_get_module(), and basically tells you that no installed image module claimed that it could recognize and knew how to parse the data from the file.


If your system lists BMP as supported, are you sure your file is correctly formatted? As i recall, the file header should start with the characters "B" and "M".

(Note that the pixbuf loader expects you to write all the data that would be in the file, header and all, even if compressed. If you just have the uncompressed image data, then Gtk2::Gdk::Pixbuf::new_from_data is more what you need.)


If you're absolutely certain that BMP is supported by your gtk+ and that your data is correct, try forcing the loader to recognize the mime type:

$loader = Gtk2::Gdk::PixbufLoader->new_with_mime_type ('image/ bmp');

(Note: on older versions of the Gtk2 binding, new_with_mime_type() was misbound as a function.)

--
Diane, ten-oh-three, Great Northern Hotel.
Sheriff Truman and I have just been with the one-armed man, or what's left of him. In another time, another culture, he may have been a seer, or a shaman priest, but in our world, he's a shoe salesman, and lives among the shadows.
-- Special Agent Dale Cooper




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