Jonathon,
Oh this was so close. After some fidling I got things to almost work.
But then I was just getting garbage near where I thought cairo should
be rendering text onto the pixbuf.
I ran across this post:
http://lists.freedesktop.org/archives/cairo/2004-February/001005.html
which mentions that cairo and GdkPixbuf have different structures for
the data stored in them, which could explain the garbage I was seeing.
The only thing I've got left is to create a scratch cairo surface,
render text to it, then copy the pixel pattern into the pixbuf by
hand.
Thanks,
Paul Davis
On 4/30/07, Jonathon Jongsma <jonathon jongsma gmail com> wrote:
> On 4/30/07, Paul Davis <pjdavis engineering uiowa edu> wrote:
> > John,
> >
> > Thanks for the code. I managed to get a C++ version working.
> >
> > Although, as I was worried, its slower than molasses. The basic flow
> > is more or less like this:
> >
> > Copy pixbuf to pixmap
> > render text on top of pixmap
> > Create temporary pixbuf from pixmap
> > copy from pixbuf back to original pixbuf.
> >
> > If anyone has any ideas on how to make this faster, I'd much appreciate it.
> >
> > Thanks,
> > Paul Davis
>
> just an idea... Could you use the Gdk::Pixbuf::get_pixels(),
> get_rowstride(), get_width(), get_height() functions and use this raw
> data to create a cairo surface using this data with
> Cairo::Surface::create (unsigned char *data, Format format, int width,
> int height, int stride) (or if you're using plain cairo, then you'd
> use cairo_image_surface_create_for_data())? Then you could just draw
> on it as you would any other cairo surface... Would that work? would
> It be faster? I don't know.
>
> --
> jonner
>