OK, I implemented this function.
It's better to implement these functions which original libraries support,
not find workarround.
Anyway, thanks for your suggestion ;).
On Wed, 11 Aug 2004 21:04:28 +0100
Geoff Youngs <g@...> wrote:
> Charles Yates wrote:
> >Hi all,
> >In my C bindings (generated with swig), I obtain a raster which contains
> >an RGB image (3 bytes per pixel). I can't seem to find a way to map that
> >to a pixbuf though.
> >The only thing I've managed to do with the pixbuf so far is create it
> >with a file or use the new and invoke the fill! method. I had hoped that
> >I could at least fall back on the pixels property and manually copy over
> >the bytes from the raster, but I failed to get that to work.
> The Ruby/GdkPixbuf bindings don't wrap gdk_pixbuf_new_from_data(), so if
> you want to use it, (at least for now) you'll need to write C.
> I would imagine (completely untested) that you'd want to use something like:
> char *data = pixel data
> int data_len = length of pixel data
> int img_width = width of image in pixels
> int img_height = height of image in pixels
> pixbuf= gdk_pixbuf_new_from_data(data, /* data returned by C ext func */
> GDK_COLORSPACE_RGB, /*
> colour space */
> FALSE, /* has_alpha */
> 8, /* single byte per
> colour entry */
> (data_len / img_height), /*
> bytes per row */
> NULL, /* or, more usefully,
> a function to free above data */
> If you use the installed Ruby/Gnome2 headers, then it should be possible
> to just return the pixbuf using the GOBJ2RVAL(pixbuf) macro to convert
> it to a VALUE.
> Gdk::Pixubf#pixels= is an automatically created property accessor, but
> it doesn't seem to do anything useful.
> If you want a more dynamic solution, I don't think that the dl library
> will help (it can't deal sensibly with ruby VALUEs) but ruby-tcc can
> (See RAA). See the attached for a program which loads a pixbuf, gets
> the pixel data, draws a narrow black line half-way down and then creates
> a new pixbuf from the pixel data. It then continues drawing black lines
> until it reaches the bottom of the image.
.:% Masao Mutoh<mutoh@...>