Mercurial > hg > dmlib
annotate tools/libgfx.h @ 2310:75216bf67fd2
Bump copyright.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 09 Jul 2019 10:27:40 +0300 |
parents | 587b26cecf5b |
children | 82cb32297ed2 |
rev | line source |
---|---|
435 | 1 /* |
2 * Functions for loading and saving bitmap images | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
2310 | 4 * (C) Copyright 2012-2019 Tecnic Software productions (TNSP) |
435 | 5 * |
6 * Please read file 'COPYING' for information on license and distribution. | |
7 */ | |
8 #ifndef LIBMGFX_H | |
9 #define LIBMGFX_H 1 | |
10 | |
11 #include "dmlib.h" | |
1609
c29adf5ce240
Convert libgfx file format routines to use DMResource instead of stdio FILE.
Matti Hamalainen <ccr@tnsp.org>
parents:
1545
diff
changeset
|
12 #include "dmres.h" |
947
5ac8f5513978
Delete useless include line.
Matti Hamalainen <ccr@tnsp.org>
parents:
929
diff
changeset
|
13 |
435 | 14 |
15 #ifdef __cplusplus | |
16 extern "C" { | |
17 #endif | |
18 | |
19 | |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
20 // Image formats |
435 | 21 enum |
22 { | |
1543
416d7b3ba3b2
Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1341
diff
changeset
|
23 DM_IMGFMT_PNG, |
416d7b3ba3b2
Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1341
diff
changeset
|
24 DM_IMGFMT_PPM, |
416d7b3ba3b2
Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1341
diff
changeset
|
25 DM_IMGFMT_PCX, |
2064
3617ef01c1de
Separate ILBM and PBM subformats of IFF images.
Matti Hamalainen <ccr@tnsp.org>
parents:
2047
diff
changeset
|
26 DM_IMGFMT_IFF_ILBM, |
3617ef01c1de
Separate ILBM and PBM subformats of IFF images.
Matti Hamalainen <ccr@tnsp.org>
parents:
2047
diff
changeset
|
27 DM_IMGFMT_IFF_PBM, |
2068 | 28 DM_IMGFMT_IFF_ACBM, |
1543
416d7b3ba3b2
Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1341
diff
changeset
|
29 DM_IMGFMT_RAW, |
416d7b3ba3b2
Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
1341
diff
changeset
|
30 DM_IMGFMT_ARAW, |
2047
3829c292df02
Add 'cdump' image output format, mainly for debugging purposes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1921
diff
changeset
|
31 DM_IMGFMT_CDUMP, |
435 | 32 }; |
33 | |
34 | |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
35 // Palette formats |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
36 enum |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
37 { |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
38 DM_PALFMT_ACT, |
2209
7a0af15fbe97
Add support for 'raw' 768 byte palette files.
Matti Hamalainen <ccr@tnsp.org>
parents:
2207
diff
changeset
|
39 DM_PALFMT_RAW, |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
40 }; |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
41 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
42 |
2095
80786a28caf0
Mark image format flags with the color formats they support.
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
43 // Color formats (these can be used along with DM_FMT_*) |
435 | 44 enum |
45 { | |
2157
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
46 DM_PIXFMT_PALETTE = 0x0010, |
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
47 DM_PIXFMT_GRAYSCALE = 0x0020, |
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
48 DM_PIXFMT_RGB = 0x0040, |
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
49 DM_PIXFMT_RGBA = 0x0080, |
2095
80786a28caf0
Mark image format flags with the color formats they support.
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
50 |
2157
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
51 DM_PIXFMT_ANY = 0x00f0, |
435 | 52 }; |
53 | |
54 | |
1544 | 55 // Error handling modes |
1285
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
56 enum |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
57 { |
1544 | 58 DM_ERRMODE_FAIL = 0, |
1285
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
59 DM_ERRMODE_RECOV_1, |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
60 DM_ERRMODE_RECOV_2, |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
61 }; |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
62 |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
63 |
1544 | 64 // Probe scores |
65 enum | |
66 { | |
67 DM_PROBE_SCORE_FALSE = 0, | |
68 DM_PROBE_SCORE_MAYBE = 250, | |
69 DM_PROBE_SCORE_AVG = 500, | |
70 DM_PROBE_SCORE_GOOD = 750, | |
71 DM_PROBE_SCORE_MAX = 1000, | |
72 }; | |
73 | |
74 | |
1545
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
75 // Flags for readability/writeability of formats |
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
76 enum |
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
77 { |
1759
027fb7313d85
Add a format flag for marking formats that have broken/incomplete support and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1733
diff
changeset
|
78 DM_FMT_WR = 0x0001, // Format can be written |
027fb7313d85
Add a format flag for marking formats that have broken/incomplete support and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1733
diff
changeset
|
79 DM_FMT_RD = 0x0002, // Format can be read |
027fb7313d85
Add a format flag for marking formats that have broken/incomplete support and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1733
diff
changeset
|
80 DM_FMT_RDWR = (DM_FMT_RD | DM_FMT_WR), // Read and write support |
027fb7313d85
Add a format flag for marking formats that have broken/incomplete support and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1733
diff
changeset
|
81 DM_FMT_BROKEN = 0x1000, // Support is broken/incomplete |
1545
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
82 }; |
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
83 |
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
84 |
2094
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
85 typedef struct |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
86 { |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
87 int ncolors; // number of colors in palette, if any |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
88 int ctransp; // transparency color index, -1 if none |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
89 DMColor *colors;// colors |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
90 } DMPalette; |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
91 |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
92 |
1609
c29adf5ce240
Convert libgfx file format routines to use DMResource instead of stdio FILE.
Matti Hamalainen <ccr@tnsp.org>
parents:
1545
diff
changeset
|
93 // Bitmapped image struct |
435 | 94 typedef struct |
95 { | |
2157
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
96 int pixfmt; // one of types specified by DM_PIXFMT_* |
1286 | 97 int width, height; |
98 int pitch; // bytes per scanline | |
99 int bpp; // bits per pixel | |
100 | |
1628
a549d33d543a
Add image aspect ratio information.
Matti Hamalainen <ccr@tnsp.org>
parents:
1616
diff
changeset
|
101 float aspect; // aspect ratio (vert / horiz), <= 0 if not set |
a549d33d543a
Add image aspect ratio information.
Matti Hamalainen <ccr@tnsp.org>
parents:
1616
diff
changeset
|
102 |
1286 | 103 BOOL constpal; // is the palette a const? |
2094
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
104 DMPalette *pal; // pointer to palette struct, NULL if no palette |
1286 | 105 |
929
e1378398be0f
Add size field for allocated data size in DMImage.
Matti Hamalainen <ccr@tnsp.org>
parents:
902
diff
changeset
|
106 size_t size; |
435 | 107 Uint8 *data; |
108 } DMImage; | |
109 | |
110 | |
111 typedef struct | |
112 { | |
2065
451980580189
Refactor how paletted/indexed formats are handled in libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
2064
diff
changeset
|
113 int fmtid; // DM_IMGFMT_* of target format (a bit of a kludge here) |
2157
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
114 int pixfmt; // Target color format DM_PIXFMT_* |
2148
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2146
diff
changeset
|
115 int scaleX, scaleY; // Integer scale factors (1..) |
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2146
diff
changeset
|
116 |
2221 | 117 int nplanes, bpp; // number of bitplanes to use, bits per PLANE to use |
118 int mask; // masking | |
2146 | 119 BOOL planar; // use planar format if the format supports it |
2065
451980580189
Refactor how paletted/indexed formats are handled in libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
2064
diff
changeset
|
120 int compression; // Use compression/compression level (0 = none, 9 = max) |
2221 | 121 // (not all formats support any, or more than on/off compression) |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
122 } DMImageWriteSpec; |
435 | 123 |
124 | |
125 typedef struct | |
126 { | |
2202 | 127 char *fext; // Typical filename extension |
128 char *name; // Format name / description | |
1616
36d073c45327
Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1609
diff
changeset
|
129 int fmtid; // DM_IMGFMT_* |
2157
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
130 int flags; // DM_FMT_* and DM_PIXFMT_* flags |
2202 | 131 |
435 | 132 int (*probe)(const Uint8 *buf, const size_t len); |
1886
1af79412f249
Remove the stdio FILE support from libgfx API, now only DMResource is supported.
Matti Hamalainen <ccr@tnsp.org>
parents:
1809
diff
changeset
|
133 int (*read)(DMResource *fp, DMImage **pimg); |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
134 int (*write)(DMResource *fp, const DMImage *pimg, const DMImageWriteSpec *spec); |
435 | 135 } DMImageFormat; |
136 | |
137 | |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
138 typedef struct |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
139 { |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
140 char *fext; // Typical filename extension |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
141 char *name; // Format name / description |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
142 int fmtid; // DM_PALFMT_* |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
143 int flags; // DM_FMT_* |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
144 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
145 int (*probe)(const Uint8 *buf, const size_t len); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
146 int (*read)(DMResource *fp, DMPalette **ppal); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
147 int (*write)(DMResource *fp, const DMPalette *ppal); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
148 } DMPaletteFormat; |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
149 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
150 |
1616
36d073c45327
Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1609
diff
changeset
|
151 extern const DMImageFormat dmImageFormatList[]; |
36d073c45327
Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1609
diff
changeset
|
152 extern const int ndmImageFormatList; |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
153 extern const DMPaletteFormat dmPaletteFormatList[]; |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
154 extern const int ndmPaletteFormatList; |
1285
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
155 extern int dmGFXErrorMode; |
435 | 156 |
157 | |
1286 | 158 DMImage * dmImageAlloc(const int width, const int height, const int format, const int bpp); |
435 | 159 void dmImageFree(DMImage *img); |
1286 | 160 int dmImageGetBytesPerPixel(const int format); |
2093
d17512dbb4ef
Some work on reading >8bpp images.
Matti Hamalainen <ccr@tnsp.org>
parents:
2092
diff
changeset
|
161 int dmImageGetBitsPerPixel(const int format); |
1616
36d073c45327
Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1609
diff
changeset
|
162 int dmImageProbeGeneric(const Uint8 *buf, const size_t len, const DMImageFormat **fmt, int *index); |
2100
81fb21dd3265
Add dmGetNPlanesFromNColors() and use it.
Matti Hamalainen <ccr@tnsp.org>
parents:
2095
diff
changeset
|
163 int dmGetNPlanesFromNColors(const int ncolors); |
435 | 164 |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
165 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
166 int dmPaletteAlloc(DMPalette **ppal, const int ncolors, const int ctransp); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
167 int dmPaletteResize(DMPalette **ppal, const int ncolors); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
168 void dmPaletteFree(DMPalette *pal); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
169 int dmPaletteCopy(DMPalette **pdst, const DMPalette *src); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
170 int dmPaletteProbeGeneric(const Uint8 *buf, const size_t len, const DMPaletteFormat **fmt, int *index); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
171 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
172 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
173 int dmReadACTPalette(DMResource *fp, DMPalette **pdst); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
174 int dmWriteACTPalette(DMResource *fp, const DMPalette *pdst); |
2293
587b26cecf5b
Add read/write RAW palette function prototypes to public header.
Matti Hamalainen <ccr@tnsp.org>
parents:
2221
diff
changeset
|
175 int dmReadRAWPalette(DMResource *fp, DMPalette **pdst); |
587b26cecf5b
Add read/write RAW palette function prototypes to public header.
Matti Hamalainen <ccr@tnsp.org>
parents:
2221
diff
changeset
|
176 int dmWriteRAWPalette(DMResource *fp, const DMPalette *ppal); |
487
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
177 |
435 | 178 |
1886
1af79412f249
Remove the stdio FILE support from libgfx API, now only DMResource is supported.
Matti Hamalainen <ccr@tnsp.org>
parents:
1809
diff
changeset
|
179 int dmWriteImageData(const DMImage *img, void *cbdata, |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
180 int (*writeRowCB)(void *, const Uint8 *, const size_t), const DMImageWriteSpec *spec); |
1886
1af79412f249
Remove the stdio FILE support from libgfx API, now only DMResource is supported.
Matti Hamalainen <ccr@tnsp.org>
parents:
1809
diff
changeset
|
181 |
435 | 182 |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
183 int dmWriteIFFMasterRAWHeader(DMResource *fp, const char *filename, const char *prefix, const DMImage *img, const DMImageWriteSpec *spec); |
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
184 int dmWriteRAWImage(DMResource *fp, const DMImage *img, const DMImageWriteSpec *spec); |
435 | 185 |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
186 int dmWritePPMImage(DMResource *fp, const DMImage *img, const DMImageWriteSpec *spec); |
2092
614b161c0aa5
Initial support for reading PPM/PGM.
Matti Hamalainen <ccr@tnsp.org>
parents:
2086
diff
changeset
|
187 int dmReadPPMImage(DMResource *fp, DMImage **pimg); |
435 | 188 |
189 #ifdef DM_USE_LIBPNG | |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
190 int dmWritePNGImage(DMResource *fp, const DMImage *img, const DMImageWriteSpec *spec); |
1886
1af79412f249
Remove the stdio FILE support from libgfx API, now only DMResource is supported.
Matti Hamalainen <ccr@tnsp.org>
parents:
1809
diff
changeset
|
191 int dmReadPNGImage(DMResource *fp, DMImage **pimg); |
435 | 192 #endif |
193 | |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
194 int dmWritePCXImage(DMResource *fp, const DMImage *img, const DMImageWriteSpec *spec); |
1886
1af79412f249
Remove the stdio FILE support from libgfx API, now only DMResource is supported.
Matti Hamalainen <ccr@tnsp.org>
parents:
1809
diff
changeset
|
195 int dmReadPCXImage(DMResource *fp, DMImage **pimg); |
435 | 196 |
1892
cbc911ffd21e
Rename ILBM functions to IFF, which is more approriate as we support both ILBM and PBM variants of the IFF images.
Matti Hamalainen <ccr@tnsp.org>
parents:
1886
diff
changeset
|
197 int dmReadIFFImage(DMResource *fp, DMImage **pimg); |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
198 int dmWriteIFFImage(DMResource *fp, const DMImage *img, const DMImageWriteSpec *spec); |
1809
a20655e40e6c
Move ILBM function declarations to position that better reflects their
Matti Hamalainen <ccr@tnsp.org>
parents:
1801
diff
changeset
|
199 |
435 | 200 |
2202 | 201 // |
202 // Simplistic bitstream reading and writing | |
203 // | |
1309
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
204 typedef struct _DMBitStreamContext |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
205 { |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
206 void *handle; |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
207 |
2086
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
208 int (*putByte)(struct _DMBitStreamContext *ctx); |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
209 int (*getByte)(struct _DMBitStreamContext *ctx); |
1309
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
210 |
2086
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
211 unsigned int |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
212 outBuf, outBitCount, outByteCount, |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
213 inBuf, inBitCount, inByteCount; |
1309
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
214 } DMBitStreamContext; |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
215 |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
216 |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
217 void dmInitBitStreamContext(DMBitStreamContext *ctx); |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
218 int dmFlushBitStream(DMBitStreamContext *ctx); |
2086
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
219 int dmInitBitStreamRes(DMBitStreamContext *ctx, DMResource *fp); |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
220 |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
221 int dmPutBits(DMBitStreamContext *ctx, const unsigned int val, const unsigned int n); |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
222 int dmGetBits(DMBitStreamContext *ctx, unsigned int *val, const unsigned int n); |
1309
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
223 |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
224 |
435 | 225 #ifdef __cplusplus |
226 } | |
227 #endif | |
228 | |
229 #endif // LIBMGFX_H |