loaders: BMP: Experimental BMP writer for RGB888.
[gfxprim.git] / include / loaders / GP_BMP.h
blobe5ad3a710849f97a8525857dfb7dce2674736440
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-2013 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
23 #ifndef LOADERS_GP_BMP_H
24 #define LOADERS_GP_BMP_H
26 #include "core/GP_Context.h"
27 #include "core/GP_ProgressCallback.h"
30 * The possible errno values:
32 * - Anything FILE operation may return (fopen(), fclose(), fseek(), ...).
33 * - EIO for fread()/fwrite() failure
34 * - ENOSYS for not implemented bitmap format
35 * - ENOMEM from malloc()
36 * - EILSEQ for wrong image signature/data
37 * - ECANCELED when call was aborted from callback
41 * Opens up a bmp file, checks signature, parses metadata.
43 * The file, width, height and pixel type are filled upon succcessful return.
45 * Upon failure, non zero return value is returned and errno is filled.
47 int GP_OpenBMP(const char *src_path, FILE **f,
48 GP_Size *w, GP_Size *h, GP_PixelType *pixel_type);
51 * Reads a BMP from a opened file.
53 * Upon successful return, context to store bitmap is allocated and image is
54 * loaded.
56 * Upon failure NULL is returned and errno is filled.
58 GP_Context *GP_ReadBMP(FILE *f, GP_ProgressCallback *callback);
61 * Does both GP_OpenBMP and GP_ReadBMP.
63 GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
66 * Saves BMP to a file. Zero is returned on succes. Upon failure non-zero is
67 * returned and errno is filled accordingly.
69 int GP_SaveBMP(const GP_Context *src, const char *dst_path,
70 GP_ProgressCallback *callback);
73 * Match BMP signature.
75 int GP_MatchBMP(const void *buf);
77 #endif /* LOADERS_GP_BMP_H */