[cairo] Patch for cairo - high resolution images in PDF surface.

Behdad Esfahbod behdad at behdad.org
Sun Nov 26 17:37:59 PST 2006


On Sat, 2006-11-25 at 22:24 -0500, Andrew McRae wrote:
> Comrades,
> Attached is a patch generated against the git mainline - I wasn't
> entirely sure if the right thing to do was to send it here or somewhere
> else. At least I'll learn the right way to do it for next time! :-)
> 
> This patch allows higher resolution images to be embedded in
> PDF surfaces - the idea is that you can set the fallback resolution
> on the image, and the PDF surface can use this as a hint for the
> DPI of the image. One part of the change is to have a flag to
> remember when the fallback resolution is actually set (as opposed
> to just having default values).
> 
>     surface = cairo_pdf_surface_create("test.pdf",
>                         8 * 72.0, 10 * 72.0);
>     img = cairo_image_surface_create_from_png("large.png");
>     cr = cairo_create (surface);
>     // Use 300 DPI for image.
>     cairo_surface_set_fallback_resolution(img, 300.0, 300.0);
>     // Use 1/2 inch margin.
>     cairo_set_source_surface(cr, img, 36.0, 36.0);
>     cairo_paint(cr);
>     cairo_show_page(cr);
> 
> Feedback welcome...
> Cheers,
> Andrew McRae

So, if I understand your patch correctly, you are making it to use the
image resolution instead of assuming a 1:1 mapping between image and PDF
device units.  That may be useful, but only if implemented on ALL
operations, not only painting an image into a PDF.  On the other hand,
it complicates cairo's simple model without much, if any, advantage.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list