Re: loading an image from data, not file

On Jan 19, 2005, at 10:03 AM, zentara wrote:

Anyways, the code below works fine when loading the image new_from_file, but all I get is a bunch of colored pixels when trying new_from_data.

I'm guessing my "pack" is wrong, since the error I get is
 Argument "M-^?M-XM-^?M-`\0^PJFIF\0^A^B\0\0d\0d\0\0M-^?M-l\...
" isn't numeric in pack at ./image-viewport-from-data line 31.

The JFIF is the dead giveaway. You're passing JPEG-encoded data rather than uncompressed image data.

gdk_pixbuf_new_from_data() wants uncompressed, packed 24-bit RGB pixel data: creating.html#gdk-pixbuf-new-from-data

Use Gtk2::Gdk::Pixbuf::new_from_data() if you have created an image out of thin air or already have uncompressed data. See Gtk2/examples/ for an example: examples/

Use Gtk2::Gdk::PixbufLoader if you need to load image data in a compressed format (e.g. from a stream or whatever). Example here:

I bring the rock, and provided it is fiscally responsible, I will bring the funk as well. And that's fo-shizzle.
        -- Saturday Night Live

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