annotate tools/libgfx.h @ 2202:455a3849b8ac

Comments and cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 14 Jun 2019 01:56:47 +0300
parents 9a9493809b3a
children 1ea48084055e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Functions for loading and saving bitmap images
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
2066
63284e9ad95e Bump copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 2065
diff changeset
4 * (C) Copyright 2012-2018 Tecnic Software productions (TNSP)
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 *
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 */
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #ifndef LIBMGFX_H
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #define LIBMGFX_H 1
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 #ifdef __cplusplus
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 extern "C" {
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #endif
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 enum
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 {
1543
416d7b3ba3b2 Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents: 1341
diff changeset
22 DM_IMGFMT_PNG,
416d7b3ba3b2 Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents: 1341
diff changeset
23 DM_IMGFMT_PPM,
416d7b3ba3b2 Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents: 1341
diff changeset
24 DM_IMGFMT_PCX,
2064
3617ef01c1de Separate ILBM and PBM subformats of IFF images.
Matti Hamalainen <ccr@tnsp.org>
parents: 2047
diff changeset
25 DM_IMGFMT_IFF_ILBM,
3617ef01c1de Separate ILBM and PBM subformats of IFF images.
Matti Hamalainen <ccr@tnsp.org>
parents: 2047
diff changeset
26 DM_IMGFMT_IFF_PBM,
2068
e4dc8fbaa5ad Improve IFF probing.
Matti Hamalainen <ccr@tnsp.org>
parents: 2066
diff changeset
27 DM_IMGFMT_IFF_ACBM,
1543
416d7b3ba3b2 Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents: 1341
diff changeset
28 DM_IMGFMT_RAW,
416d7b3ba3b2 Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
Matti Hamalainen <ccr@tnsp.org>
parents: 1341
diff changeset
29 DM_IMGFMT_ARAW,
2047
3829c292df02 Add 'cdump' image output format, mainly for debugging purposes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1921
diff changeset
30 DM_IMGFMT_CDUMP,
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 };
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
2095
80786a28caf0 Mark image format flags with the color formats they support.
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
34 // Color formats (these can be used along with DM_FMT_*)
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 enum
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 {
2157
9a9493809b3a Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents: 2156
diff changeset
37 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
38 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
39 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
40 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
41
2157
9a9493809b3a Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents: 2156
diff changeset
42 DM_PIXFMT_ANY = 0x00f0,
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 };
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
1544
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
46 // 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
47 enum
e4bda4909d72 Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
48 {
1544
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
49 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
50 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
51 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
52 };
e4bda4909d72 Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
53
e4bda4909d72 Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
54
1544
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
55 // Probe scores
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
56 enum
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
57 {
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
58 DM_PROBE_SCORE_FALSE = 0,
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
59 DM_PROBE_SCORE_MAYBE = 250,
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
60 DM_PROBE_SCORE_AVG = 500,
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
61 DM_PROBE_SCORE_GOOD = 750,
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
62 DM_PROBE_SCORE_MAX = 1000,
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
63 };
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
64
48823642c4fb Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1543
diff changeset
65
1545
3b613fcbf3ff Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1544
diff changeset
66 // 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
67 enum
3b613fcbf3ff Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1544
diff changeset
68 {
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
69 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
70 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
71 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
72 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
73 };
3b613fcbf3ff Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1544
diff changeset
74
3b613fcbf3ff Improve how format read/write capabilities are marked and shown.
Matti Hamalainen <ccr@tnsp.org>
parents: 1544
diff changeset
75
2094
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
76 typedef struct
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
77 {
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
78 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
79 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
80 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
81 } DMPalette;
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
82
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
83
1609
c29adf5ce240 Convert libgfx file format routines to use DMResource instead of stdio FILE.
Matti Hamalainen <ccr@tnsp.org>
parents: 1545
diff changeset
84 // Bitmapped image struct
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 typedef struct
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 {
2157
9a9493809b3a Rename DM_COLFMT_* constants to DM_PIXFMT_* and the 'format' field of DMImage
Matti Hamalainen <ccr@tnsp.org>
parents: 2156
diff changeset
87 int pixfmt; // one of types specified by DM_PIXFMT_*
1286
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
88 int width, height;
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
89 int pitch; // bytes per scanline
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
90 int bpp; // bits per pixel
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
91
1628
a549d33d543a Add image aspect ratio information.
Matti Hamalainen <ccr@tnsp.org>
parents: 1616
diff changeset
92 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
93
1286
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
94 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
95 DMPalette *pal; // pointer to palette struct, NULL if no palette
1286
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
96
929
e1378398be0f Add size field for allocated data size in DMImage.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
97 size_t size;
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 Uint8 *data;
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 } DMImage;
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 typedef struct
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 {
2065
451980580189 Refactor how paletted/indexed formats are handled in libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 2064
diff changeset
104 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
105 int pixfmt; // Target color format DM_PIXFMT_*
2148
487157934904 Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2146
diff changeset
106 int scaleX, scaleY; // Integer scale factors (1..)
487157934904 Clarifications in comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2146
diff changeset
107
2146
26f21e487fe2 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
108 int nplanes, bpp, mask; // number of planes, bits per PLANE, masking
26f21e487fe2 Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2100
diff changeset
109 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
110 int compression; // Use compression/compression level (0 = none, 9 = max)
2156
e6ec7fad9ce2 Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents: 2148
diff changeset
111 } DMImageWriteSpec;
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 typedef struct
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 {
2202
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
116 char *fext; // Typical filename extension
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
117 char *name; // Format name / description
1616
36d073c45327 Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1609
diff changeset
118 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
119 int flags; // DM_FMT_* and DM_PIXFMT_* flags
2202
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
120
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 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
122 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
123 int (*write)(DMResource *fp, const DMImage *pimg, const DMImageWriteSpec *spec);
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 } DMImageFormat;
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
1616
36d073c45327 Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1609
diff changeset
127 extern const DMImageFormat dmImageFormatList[];
36d073c45327 Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1609
diff changeset
128 extern const int ndmImageFormatList;
1285
e4bda4909d72 Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
129 extern int dmGFXErrorMode;
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
1286
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
132 DMImage * dmImageAlloc(const int width, const int height, const int format, const int bpp);
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 void dmImageFree(DMImage *img);
1286
b812fad6f33e Work on libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 1285
diff changeset
134 int dmImageGetBytesPerPixel(const int format);
2093
d17512dbb4ef Some work on reading >8bpp images.
Matti Hamalainen <ccr@tnsp.org>
parents: 2092
diff changeset
135 int dmImageGetBitsPerPixel(const int format);
1616
36d073c45327 Refactor the format handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 1609
diff changeset
136 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
137 int dmGetNPlanesFromNColors(const int ncolors);
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
2094
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
139 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, const BOOL alpha);
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
140 int dmPaletteAlloc(DMPalette **ppal, const int ncolors, const int ctransp);
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
141 int dmPaletteResize(DMPalette **ppal, const int ncolors);
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
142 void dmPaletteFree(DMPalette *pal);
4276b8c0fef0 Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents: 2093
diff changeset
143 int dmPaletteCopy(DMPalette **pdst, const DMPalette *src);
487
b89598501cec Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents: 462
diff changeset
144
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145
1886
1af79412f249 Remove the stdio FILE support from libgfx API, now only DMResource is supported.
Matti Hamalainen <ccr@tnsp.org>
parents: 1809
diff changeset
146 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
147 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
148
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149
2156
e6ec7fad9ce2 Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents: 2148
diff changeset
150 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
151 int dmWriteRAWImage(DMResource *fp, const DMImage *img, const DMImageWriteSpec *spec);
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
2156
e6ec7fad9ce2 Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents: 2148
diff changeset
153 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
154 int dmReadPPMImage(DMResource *fp, DMImage **pimg);
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 #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
157 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
158 int dmReadPNGImage(DMResource *fp, DMImage **pimg);
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 #endif
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
2156
e6ec7fad9ce2 Rename DMImageConvSpec to DMImageWriteSpec to better reflec the struct's purpose.
Matti Hamalainen <ccr@tnsp.org>
parents: 2148
diff changeset
161 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
162 int dmReadPCXImage(DMResource *fp, DMImage **pimg);
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
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
164 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
165 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
166
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167
2202
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
168 //
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
169 // Simplistic bitstream reading and writing
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2157
diff changeset
170 //
1309
5ad7d780a09b Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 1307
diff changeset
171 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
172 {
5ad7d780a09b Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 1307
diff changeset
173 void *handle;
5ad7d780a09b Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 1307
diff changeset
174
2086
aedadff9e116 Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2070
diff changeset
175 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
176 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
177
2086
aedadff9e116 Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2070
diff changeset
178 unsigned int
aedadff9e116 Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2070
diff changeset
179 outBuf, outBitCount, outByteCount,
aedadff9e116 Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2070
diff changeset
180 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
181 } DMBitStreamContext;
5ad7d780a09b Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 1307
diff changeset
182
5ad7d780a09b Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 1307
diff changeset
183
5ad7d780a09b Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 1307
diff changeset
184 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
185 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
186 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
187
aedadff9e116 Implement dmGetBits() to the DMBitStreamContext API. Also improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2070
diff changeset
188 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
189 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
190
5ad7d780a09b Move bitstream reading functions to libgfx, as they were only used there.
Matti Hamalainen <ccr@tnsp.org>
parents: 1307
diff changeset
191
435
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 #ifdef __cplusplus
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 }
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 #endif
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
e4a3f183e463 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 #endif // LIBMGFX_H