added 3dengfx into the repo, probably not the correct version for this
[summerhack] / src / 3dengfx / src / gfx / image.h
1 /*
2 Copyright 2004 John Tsiombikas <nuclear@siggraph.org>
3
4 This is a small image library.
5
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 /* image file handling library
22  *
23  * author: John Tsiombikas 2003
24  * modified: John Tsiombikas 2004
25  */
26
27 #ifndef IMAGE_H_
28 #define IMAGE_H_
29
30 #include "3dengfx_config.h"
31
32 /* always compile support for image formats that
33  * don't create any library dependencies.
34  */
35 #define IMGLIB_USE_TGA
36 #define IMGLIB_USE_PPM
37
38 /* for jpeg and png, make the default be to compile them in,
39  * unless explicitly disabled.
40  */
41 #ifndef IMGLIB_NO_JPEG
42 #define IMGLIB_USE_JPEG
43 #endif  /* IMGLIB_NO_JPEG */
44
45 #ifndef IMGLIB_NO_PNG
46 #define IMGLIB_USE_PNG
47 #endif  /* IMGLIB_NO_PNG */
48
49
50 enum image_file_format {
51         IMG_FMT_PNG,
52         IMG_FMT_JPEG,
53         IMG_FMT_TGA,
54         IMG_FMT_PPM
55 };
56
57 enum {
58         IMG_SAVE_ALPHA          = 1,
59         IMG_SAVE_COMPRESS       = 2,
60         IMG_SAVE_INVERT         = 4
61 };
62
63 #ifdef __cplusplus
64 extern "C" {
65 #endif  /* __cplusplus */
66
67 /* load_image() loads the specified image from file, returns the pixel data
68  * in 32bit mode, and changes xsz and ysz to the size of the image
69  */
70 void *load_image(const char *fname, unsigned long *xsz, unsigned long *ysz);
71
72 /* deallocate the image data with this function
73  * note: provided for consistency, simply calls free()
74  */
75 void free_image(void *img);
76
77 /* save the supplied image data in a file of the specified format */
78 int save_image(const char *fname, void *pixels, unsigned long xsz, unsigned long ysz, enum image_file_format fmt);
79
80 /* set/get save image options */
81 void set_image_save_flags(unsigned int flags);
82 unsigned int get_image_save_flags(void);
83
84 #ifdef __cplusplus
85 }
86 #endif  /* __cplusplus */
87         
88 #endif  /* IMAGE_H_ */