Mercurial > hg > dmlib
annotate tools/libgfx.h @ 2539:c6ee41fd98dd
Bump copyright years.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 02 Jan 2021 11:42:17 +0200 |
parents | 637a310e3f27 |
children | 9807ae37ad69 |
rev | line source |
---|---|
435 | 1 /* |
2 * Functions for loading and saving bitmap images | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
2539 | 4 * (C) Copyright 2012-2021 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 | |
2469
637a310e3f27
Adjust DM_FMT_* flag values slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2467
diff
changeset
|
75 // Flags for readability/writeability support of formats |
637a310e3f27
Adjust DM_FMT_* flag values slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2467
diff
changeset
|
76 // These can be combined with DM_PIXFMT_* for some uses. |
1545
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
77 enum |
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
78 { |
2469
637a310e3f27
Adjust DM_FMT_* flag values slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2467
diff
changeset
|
79 DM_FMT_WR = 0x00001, // Format can be written |
637a310e3f27
Adjust DM_FMT_* flag values slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2467
diff
changeset
|
80 DM_FMT_RD = 0x00002, // Format can be read |
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
|
81 DM_FMT_RDWR = (DM_FMT_RD | DM_FMT_WR), // Read and write support |
2469
637a310e3f27
Adjust DM_FMT_* flag values slightly.
Matti Hamalainen <ccr@tnsp.org>
parents:
2467
diff
changeset
|
82 DM_FMT_BROKEN = 0x00008, // 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
|
83 }; |
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
84 |
3b613fcbf3ff
Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents:
1544
diff
changeset
|
85 |
2094
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
86 typedef struct |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
87 { |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
88 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
|
89 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
|
90 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
|
91 } DMPalette; |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
92 |
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2093
diff
changeset
|
93 |
1609
c29adf5ce240
Convert libgfx file format routines to use DMResource instead of stdio FILE.
Matti Hamalainen <ccr@tnsp.org>
parents:
1545
diff
changeset
|
94 // Bitmapped image struct |
435 | 95 typedef struct |
96 { | |
2157
9a9493809b3a
Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents:
2156
diff
changeset
|
97 int pixfmt; // one of types specified by DM_PIXFMT_* |
1286 | 98 int width, height; |
99 int pitch; // bytes per scanline | |
100 int bpp; // bits per pixel | |
101 | |
1628
a549d33d543a
Add image aspect ratio information.
Matti Hamalainen <ccr@tnsp.org>
parents:
1616
diff
changeset
|
102 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
|
103 |
1286 | 104 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
|
105 DMPalette *pal; // pointer to palette struct, NULL if no palette |
1286 | 106 |
929
e1378398be0f
Add size field for allocated data size in DMImage.
Matti Hamalainen <ccr@tnsp.org>
parents:
902
diff
changeset
|
107 size_t size; |
435 | 108 Uint8 *data; |
109 } DMImage; | |
110 | |
111 | |
112 typedef struct | |
113 { | |
2065
451980580189
Refactor how paletted/indexed formats are handled in libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
2064
diff
changeset
|
114 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
|
115 int pixfmt; // Target color format DM_PIXFMT_* |
2148
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2146
diff
changeset
|
116 int scaleX, scaleY; // Integer scale factors (1..) |
487157934904
Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2146
diff
changeset
|
117 |
2221 | 118 int nplanes, bpp; // number of bitplanes to use, bits per PLANE to use |
119 int mask; // masking | |
2146 | 120 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
|
121 int compression; // Use compression/compression level (0 = none, 9 = max) |
2221 | 122 // (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
|
123 } DMImageWriteSpec; |
435 | 124 |
125 | |
126 typedef struct | |
127 { | |
2202 | 128 char *fext; // Typical filename extension |
129 char *name; // Format name / description | |
1616
36d073c45327
Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1609
diff
changeset
|
130 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
|
131 int flags; // DM_FMT_* and DM_PIXFMT_* flags |
2202 | 132 |
435 | 133 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
|
134 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
|
135 int (*write)(DMResource *fp, const DMImage *pimg, const DMImageWriteSpec *spec); |
435 | 136 } DMImageFormat; |
137 | |
138 | |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
139 typedef struct |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
140 { |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
141 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
|
142 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
|
143 int fmtid; // DM_PALFMT_* |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
144 int flags; // DM_FMT_* |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
145 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
146 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
|
147 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
|
148 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
|
149 } DMPaletteFormat; |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
150 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
151 |
2458
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
152 // |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
153 // Global variables |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
154 // |
1616
36d073c45327
Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1609
diff
changeset
|
155 extern const DMImageFormat dmImageFormatList[]; |
36d073c45327
Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
1609
diff
changeset
|
156 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
|
157 extern const DMPaletteFormat dmPaletteFormatList[]; |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
158 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
|
159 extern int dmGFXErrorMode; |
435 | 160 |
161 | |
2458
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
162 // |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
163 // Palette handling |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
164 // |
2207
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
165 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
|
166 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
|
167 void dmPaletteFree(DMPalette *pal); |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
168 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
|
169 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
|
170 |
1ea48084055e
Add functionality for separate palette file handling, reading, writing and
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
171 |
2458
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
172 int dmReadACTPalette(DMResource *fp, DMPalette **pdst); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
173 int dmWriteACTPalette(DMResource *fp, const DMPalette *pdst); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
174 int dmReadRAWPalette(DMResource *fp, DMPalette **pdst); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
175 int dmWriteRAWPalette(DMResource *fp, const DMPalette *ppal); |
487
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
176 |
435 | 177 |
2458
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
178 // |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
179 // Image formats |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
180 // |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
181 DMImage * dmImageAlloc(const int width, const int height, const int format, const int bpp); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
182 void dmImageFree(DMImage *img); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
183 int dmImageGetBytesPerPixel(const int format); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
184 int dmImageGetBitsPerPixel(const int format); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
185 int dmImageProbeGeneric(const Uint8 *buf, const size_t len, const DMImageFormat **fmt, int *index); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
186 int dmGetNPlanesFromNColors(const int ncolors); |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
187 |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
188 int dmWriteImageData(const DMImage *img, void *cbdata, |
f6278408bfae
Reorder the function prototypes, cosmetics, comments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2371
diff
changeset
|
189 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
|
190 |
435 | 191 |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
192 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
|
193 int dmWriteRAWImage(DMResource *fp, const DMImage *img, const DMImageWriteSpec *spec); |
435 | 194 |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
195 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
|
196 int dmReadPPMImage(DMResource *fp, DMImage **pimg); |
435 | 197 |
198 #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
|
199 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
|
200 int dmReadPNGImage(DMResource *fp, DMImage **pimg); |
435 | 201 #endif |
202 | |
2156
e6ec7fad9ce2
Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents:
2148
diff
changeset
|
203 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
|
204 int dmReadPCXImage(DMResource *fp, DMImage **pimg); |
435 | 205 |
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
|
206 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
|
207 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
|
208 |
435 | 209 |
2202 | 210 // |
211 // Simplistic bitstream reading and writing | |
212 // | |
1309
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
213 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
|
214 { |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
215 void *handle; |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
216 |
2086
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
217 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
|
218 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
|
219 |
2086
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
220 unsigned int |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
221 outBuf, outBitCount, outByteCount, |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
222 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
|
223 } DMBitStreamContext; |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
224 |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
225 |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 |
aedadff9e116
Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2070
diff
changeset
|
230 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
|
231 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
|
232 |
5ad7d780a09b
Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents:
1307
diff
changeset
|
233 |
435 | 234 #ifdef __cplusplus |
235 } | |
236 #endif | |
237 | |
238 #endif // LIBMGFX_H |