[cairo] PNG backend

Olivier Andrieu oliv__a at users.sourceforge.net
Tue Feb 17 07:48:28 PST 2004


 Carl Worth [Tuesday 17 February 2004] :
 > A few (fairly minor) comments:
 > 
 >  > | void
 >  > | cairo_set_target_png (cairo_t	*cr,
 >  > |                       FILE *file,
 >  > |                       cairo_format_t format,
 >  > |                       int width,
 >  > |                       int height,
 >  > |                       double pixels_per_inch);
 >  > | 
 >  > | cairo_surface_t *
 >  > | cairo_png_surface_create (FILE           *file,
 >  > |                           cairo_format_t format,
 >  > |                           int width,
 >  > |                           int height,
 >  > |                           double pixels_per_inch);
 > 
 > Hmm... does it make sense to require pixels_per_inch here? The
 > current image_surface backend doesn't take this, and these two
 > should probably be consistent.

Well the pixels_per_inch is mainly here to provide a return value for
the pixels_per_inch method of the backend. And it gets written in the
PNG header too. But I guess it could use the same fixed value than the
image backend.

 >  > -Requires: fontconfig libpixman @XRENDER_REQUIRES@
 >  > +Requires: fontconfig libpixman @XRENDER_REQUIRES@ libpng12
 > 
 > This should be fixed to add the libpng12 requirement only if the
 > png backend is enabled.

Right, I'll fix that.

 >  > +static cairo_status_t
 >  > +_cairo_png_surface_set_matrix (void		*abstract_surface,
 >  > +			       cairo_matrix_t	*matrix)
 >  > +{
 >  > +    cairo_png_surface_t *surface = abstract_surface;
 >  > +
 >  > +    return _cairo_image_surface_set_matrix (surface->image, matrix);
 >  > +}
 > 
 > It might be worth figuring out how to eliminate these several
 > trivial wrappers.

A way to do that would be the usual "OO in C" approach, where the
first element in cairo_png_surface_t is a cairo_image_surface_t and
then put those image methods in the cairo_png_surface_backend.

 >  > +static cairo_int_status_t
 >  > +_cairo_png_surface_fill_rectangles (void			*abstract_surface,
 >  > +				    cairo_operator_t	operator,
 >  > +				    const cairo_color_t	*color,
 >  > +				    cairo_rectangle_t	*rects,
 >  > +				    int			num_rects)
 >  > +{
 >  > +    return CAIRO_INT_STATUS_UNSUPPORTED;
 >  > +}
 > 
 > These too.

allow NULL values in the backend struct ?

-- 
   Olivier




More information about the cairo mailing list