[cairo] Problem with png in pdf documents when using acroread

Behdad Esfahbod behdad at behdad.org
Wed Apr 4 14:55:48 PDT 2007


On Wed, 2007-04-04 at 17:41 -0400, Eugeniy Meshcheryakov wrote:
> This problem can be fixed by using cairo_{save,restore} pair, but I
> think it is bug in cairo anyway.
> 
> > #include <cairo.h>
> > #include <cairo-pdf.h>
> > 
> > int 
> > main (int argc, char **argv)
> > {
> >   int i;
> >   cairo_surface_t *surface;
> >   cairo_t *cr;
> >   cairo_surface_t *image;
> > 
> >   surface = cairo_pdf_surface_create ("testme.pdf", 4.0*72, 4.0*72);    
> >   cr = cairo_create (surface);
> >   cairo_surface_destroy (surface);
> >   cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
> > 
> >   for (i = 0; i < 2; i++)
> >     {
> cairo_save(cr);
> >       cairo_rectangle(cr, 100, 100, 150, 150 );
> >       cairo_stroke(cr);
> > 
> >       image = cairo_image_surface_create_from_png ("logo.png");
> >       cairo_set_source_surface (cr, image, 30, 30);
> >       cairo_paint (cr);
> >       cairo_show_page(cr);
> cairo_restore(cr);
> >     }
> >   cairo_destroy (cr);
> >   return 0;
> > }

This is because you are setting source with cairo_set_source_surface()
and do not reset it to black by the time of cairo_stroke() in the second
run of the loop.


-- 
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