Re: No more poppler_page_render_to_pixbuf() in Ubuntu 12.04



Hi Tadej;

Yes, I finally came up with the following,

page = poppler_document_get_page(doc, page_num);
poppler_page_get_size(page, &width, &height);	
cairo_surface_t *s;
cairo_t *cr;
s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cr = cairo_create(s);
poppler_page_render(page, cr);
pixbuf = gdk_pixbuf_get_from_surface(s, 0, 0, width, height);
image = gtk_image_new_from_pixbuf(pixbuf);

with a build in GTK+-3.

I just don't understand why there was a depreciation of the older code.
Who makes these decisions?

Craig Bakalian





On Sun, 2012-04-29 at 01:36 +0200, Tadej Borovšak wrote:
> Hello.
> 
> > I used the code below to render a page of a pdf to a scrolled window in
> > a gtk application of mine. After downloading Ubuntu 12.04 I get that
> > there is no more support for poppler_page_render_to_pixbuf(). I do know
> > that we are supposed to use cairo.  But how?  How do I replace the code
> > below with cairo?  What are we supposed to use, total cairo or
> > gdk_cairo_create().
> 
> I can see 2 different ways of dealing with this API removal. To reuse
> as much existing code as possible, you can create
> cairo_image_surface_t, let poppler render your page there using
> poppler_page_render() and write your own function that will convert
> between cairo_image_surface_t and GdkPixbuf.
> 
> Another way would involve replacing GtkImage widget with
> GtkDrawingArea and drawing your page directly from expose-event/draw
> signal handler. Details will depend on whether you'll use GTK+-2 or
> GTK+-3.
> 
> Cheers,
> Tadej
> 
> 




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