[cairo] How to return nil error surface?

Gerhard Heift gerhard at heift.name
Fri Sep 28 08:05:07 PDT 2012


Hello,

I have implemented a function to load an image from a jpeg file. Now I
want to implement the error handling inside this function. I had a
look inside of cairo_image_surface_create_from_png, which returns a
private static surface for errors such as FILE_NOT_FOUND. Is it
possible for me to return such an error surface, too?

iI want to do something like this:

cairo_surface_t * surface_from_jpeg(const char *file) {
  FILE *infile;
  infile = fopen(file, "rb");
  if (infile == NULL) {
    if (errno == ENOENT) {
      return cairo_surface_nil_with_error(CAIRO_STATUS_FILE_NOT_FOUND);
    }
  }
  /* ... */
}

Thanks,
  Gerhard


More information about the cairo mailing list