loaders: PNG: add experimental support for metadata.
[gfxprim.git] / include / loaders / GP_PNG.h
blob3a8f2f8973b216f1c2f98e80790b939ff5d14907
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
25 PNG support using libpng library.
29 #ifndef LOADERS_GP_PNG_H
30 #define LOADERS_GP_PNG_H
32 #include "core/GP_ProgressCallback.h"
33 #include "core/GP_Context.h"
35 #include "GP_MetaData.h"
38 * The possible errno values:
40 * - Anything FILE operation may return (fopen(), fclose(), fseek(), ...).
41 * - EIO for png_read()/png_write() failure
42 * - ENOSYS for not implemented bitmap format
43 * - ENOMEM from malloc()
44 * - EILSEQ for wrong image signature/data
45 * - ECANCELED when call was aborted from callback
49 * Opens up file and checks signature. Upon successful return (zero is
50 * returned) the file possition would be set to eight bytes (exactly after the
51 * PNG signature).
53 int GP_OpenPNG(const char *src_path, FILE **f);
56 * Reads PNG from an open FILE. Expects the file possition set after the eight
57 * bytes PNG signature.
59 * Upon succesfull return pointer to newly allocated context is returned.
60 * Otherwise NULL is returned and errno is filled.
62 GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback);
65 * Does both GP_OpenPNG and GP_ReadPNG at once.
67 GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback);
70 * Loads png meta-data.
72 int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data);
73 int GP_LoadPNGMetaData(const char *src_path, GP_MetaData *data);
76 * Saves PNG to a file. Zero is returned on succes. Upon failure non-zero is
77 * returned and errno is filled accordingly.
79 int GP_SavePNG(const GP_Context *src, const char *dst_path,
80 GP_ProgressCallback *callback);
82 #endif /* LOADERS_GP_PNG_H */