Bug 20045 - setPaperColor in CairoOutputDev
Summary: setPaperColor in CairoOutputDev
Status: RESOLVED WONTFIX
Alias: None
Product: poppler
Classification: Unclassified
Component: cairo backend (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium enhancement
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-10 16:15 UTC by Mihail Zenkov
Modified: 2012-02-23 03:16 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Mihail Zenkov 2009-02-10 16:15:30 UTC
It would be wonderfully if poppler provide setPaperColor for CairoOutputDev as it provided it for SplashOutputDev.
Comment 1 Carlos Garcia Campos 2009-02-22 07:22:15 UTC
I'm not sure we need it in CairoOutputDev, why not just filling the surface before rendering?
Comment 2 Mihail Zenkov 2009-02-23 16:23:22 UTC
You right. I look to demo, this way work for cairo, but not for poppler_page_render_to_pixbuf
My changes in demo to test:

diff -ur poppler-0.10.4-orig/glib/demo/render.c poppler-0.10.4/glib/demo/render.c
--- poppler-0.10.4-orig/glib/demo/render.c      2008-10-09 23:30:34.000000000 +0300
+++ poppler-0.10.4/glib/demo/render.c   2009-02-23 20:18:30.000000000 +0200
@@ -172,7 +172,7 @@
                cr = cairo_create (demo->surface);

                cairo_save (cr);
-               cairo_set_source_rgb (cr, 1, 1, 1);
+               cairo_set_source_rgb (cr, .5, .5, .5);
                cairo_rectangle (cr, 0, 0, width, height);
                cairo_fill (cr);
                cairo_restore (cr);
@@ -209,7 +209,7 @@
                timer = g_timer_new ();
                demo->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
                                               FALSE, 8, width, height);
-               gdk_pixbuf_fill (demo->pixbuf, 0xffffff);
+               gdk_pixbuf_fill (demo->pixbuf, 0x808080);
                poppler_page_render_to_pixbuf (page,
                                               x, y,
                                               width,

Comment 3 Carlos Garcia Campos 2009-02-24 01:48:47 UTC
(In reply to comment #2)
> You right. I look to demo, this way work for cairo, but not for
> poppler_page_render_to_pixbuf

yes, but that's an issue in the glib bindings not in CairoOutputDev. I haven't look at it in detail, but I'd say it's not possible to fix it without breaking the API. Anyway, I think non cairo API will be deprecated in the glib bindings sooner or later. 
Comment 4 Adrian Johnson 2012-02-23 03:16:19 UTC
The poppler_page_render_to_pixbux api has been removed. The correct way to set the paper color is to first render to a transparent surface then paint the surface over the paper color. eg

    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                          IMAGE_DPI*width/72.0,
                                          IMAGE_DPI*height/72.0);
    cr = cairo_create (surface);
    cairo_scale (cr, IMAGE_DPI/72.0, IMAGE_DPI/72.0);
    poppler_page_render (page, cr);
    cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
    cairo_set_source_rgb (cr, 1, 1, 1);  // Set paper color
    cairo_paint (cr);


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.