[cairo] API shakeup: png function names

Kristian Høgsberg krh at bitplanet.net
Sun Apr 3 19:55:55 PDT 2005


John Ellson wrote:
> In the absence of updated examples,  I tried to update my code based on 
> the names of the functions
> in cairo/cairo_png.h.
> 
> I totally misinterpred the role of this function:
> 
> cairo_surface_t *
> cairo_image_surface_create_for_png (FILE *file,  int *width,  int *height);
>  
> Why not just call it:  cairo_surface_read_png  so as to be clear that it 
> is the read counterpart to the other png function?

Well, it isn't really the counterpart.  The counterpart would read a png 
into an existing image surface.  cairo_image_surface_create_for_png() is 
a surface constructor and follows the naming and parameter conventions 
for constructors.

A function to read a png file into a en existing surface might make 
sense, but I'm not sure how you would get the size of the png to make 
sure the surface is the right size.  The current approach of making the 
read function a constructor is a pretty simple and clean design, even if 
the read and write functions are not symmetric.

cheers,
Kristian



More information about the cairo mailing list