[cairo] API shakeup: png function names
ellson at research.att.com
Sun Apr 3 20:50:51 PDT 2005
Kristian Høgsberg wrote:
> 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
>> 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.
Thats a bit of a subtle distinction, but OK they are not quite symmetric.
I think the bit that first confused me was the use of "for" instead of
"from" . To me the directionality of "for" is wrong.
How about "cairo_image_surface_create_from_png"
Then, since the creation part is fairly obvious from the return type,
how about dropping the "create"
and is the "image" qualifier really necessary?
More information about the cairo