Render a RGB buffer in GnomeCanvas

Hi people.

I'm trying to render a RGB buffer (GdkPixbuf) in a GnomeCanvas. Besides,
I have a shape (GnomeCanvasShape), and with this shape I get another
alpha channel. I'll try to explain it better :-)

Firstly, the user creates a shape in the canvas, like in sodipodi
(composed by curves and lines). This shape creates a SVP, and then
render it in the canvas. After that, the user loads an image. This image
can have an alpha channel (i.e, PNG).

In the canvas, I want to render that image, but also I want to hide the
areas where there is no shape.

(Sorry for my english).

I hope that this picture helps you to understand me :-)

I think that the best way to do this is load the image with
<gdk_pixbuf_new_from_file>, then force to have an alpha channel calling to
<gdk_pixbuf_add_alpha>. When the image has to be rendered, I get the SVP
and call to <art_svp_render_aa>, passing a function which will edit the
alpha channel of the RGB buffer (that is, the return value of
<gdk_pixbuf_get_pixels>). This function read the actual value of the
alpha channelp for every point of the RGBA buffer, an edit it with a
combination of that value and the value of the SVP

Some questions,

 - GnomeCanvasShape hides its members (GnomeCanvasShapePriv). IMHO, this
   is an error, because others programs won't be able to use everything
   of it. That is, I can't use that object because I need to read the
   SVP created from GnomeCanvasPath, stored in GnomeCanvasShapePriv.fill_svp, 
   so I have to copy the code of this object in my program :-(

   Is there any way to read the fill_svp value, without copy
   gnome-canvas-shape-private.h, in my program?

 - Is there a better way to do this? I have no experience in this kind
   of applications, so I'm not sure if this is the better way to do
   the combination of alpha channels.

   I only need combine the image's alpha channel with a mask created
   from a SVP, and then render the result RGB buffer in GnomeCanvasBuf.

 - Is there some library that do this? I've seen librsvg, but
   documentation doesn't exist :-((

Thanks in advance.


Ayose Cazorla León
Debian GNU/Linux - setepo

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