Re: Render Text to Pixbuf



Ok, so, I'm wasn't entirely wrong, but I was being kind of dumb.

The 'garbage' I was seeing was me not having a large enough font size
selected.  so now I've got the text being written to the image, but
its not exactly correct.

I've posted to images so that people can see.
The first is what happens when I call cairo_surface_write_to_png().
The second is what it looks like when rendered in my application.  I
scaled the second one up so you can see the effect a bit better.

If anyone has got any crazy ideas on how to fix this, I'd be glade to
hear them :D

Thanks,
Paul Davis

On 5/1/07, Paul Davis <pjdavis engineering uiowa edu> wrote:
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
>




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