Re: Problems with pixbufs



On 05/18/04 21:57:02, Sven Neumann wrote:
Hi,

Tuomas Peippo <tuomas peippo 2ndpoint fi> writes:

> I'm trying to "blend" two pixbufs together using
gdk_pixbuf_composite
> but I'm having trouble understanding what it actually does.
>
> I was hoping that it would blend two pixbufs according to alpha
> channels e.g if I have a image with red square on white background
> which has alpha value 0 ( which I hope means fully transparent ) and
> I would like to merge it with image that has some random pixels on
> white background so I guess that gdk_pixbuf_composite() doesn't
> blend it so that only red square would transfer?

It does just that. Perhaps it would help if you could show us your
code. But please let's continue this thread on gtk-list since
gtk-devel-list is about development of GTK+.


Sven


Sorry about that, I was posting to this list first but I guess I
mistyped the address or something =).

And I'm using libart to draw stuff and then I copy it to pixbuf and then I blend it to "screen" pixbuf that holds all kind of data. I'm not sure what part of the code would be helpful but here are some lines:

/* Modified from libart example found somewhe on net */
art_u32 color = (0xFF << 24) | (0x00 <<16) | (0x00<<8) | (0xFF) ;

buffer = art_new( art_u8, 800*800*8 );

art_rgb_run_alpha( buffer, 0xFF, 0xFF, 0xFF, 255, 800*800 );
art_rgb_svp_alpha( svp, 0, 0, 800, 800, color, buffer, 800*3, NULL );

pixbuf = pixbuf->create_from_data ( (guint8*)buffer,
        Gdk::COLORSPACE_RGB, false, 8, 800, 800, 800*3 );

pixbuf = pixbuf->add_alpha( true, 255, 255, 255 );   

Pixbuf should now contain the red square. And white color should be
transparent right?

Then I try to blend it with another pixbuf like this:

pixbuf->composite(layers[0].image, 0, 0, pixbuf->get_width(), pixbuf-
get_height(), 0, 0, 1, 1,Gdk::INTERP_TILES, 255);

and I'm hoping that 255 means full opaque and it doesn't mess with pixbuf's original alpha values.

And this is actually gtkmm code but I guess all functions have pretty same name so..





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