Mercurial > hg > dmlib
annotate src/libgfx.h @ 1290:e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 18 Aug 2017 17:47:30 +0300 |
parents | 6c8b19d1d196 |
children | 2c4acbc3e7bf |
rev | line source |
---|---|
435 | 1 /* |
2 * Functions for loading and saving bitmap images | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2012 Tecnic Software productions (TNSP) | |
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" | |
947
5ac8f5513978
Delete useless include line.
Matti Hamalainen <ccr@tnsp.org>
parents:
929
diff
changeset
|
12 |
435 | 13 |
14 #ifdef __cplusplus | |
15 extern "C" { | |
16 #endif | |
17 | |
18 | |
19 enum | |
20 { | |
21 IMGFMT_PNG, | |
22 IMGFMT_PPM, | |
23 IMGFMT_PCX, | |
443
f7c9d1619c74
Beginnings of IFF ILBM reader. Not functional, only chunk parsing,
Matti Hamalainen <ccr@tnsp.org>
parents:
435
diff
changeset
|
24 IMGFMT_ILBM, |
566
d400e32b62d9
Add a slightly different raw output format.
Matti Hamalainen <ccr@tnsp.org>
parents:
487
diff
changeset
|
25 IMGFMT_RAW, |
435 | 26 IMGFMT_ARAW, |
27 | |
28 IMGFMT_LAST | |
29 }; | |
30 | |
31 | |
32 enum | |
33 { | |
34 DM_IFMT_PALETTE, | |
35 DM_IFMT_RGB, | |
36 DM_IFMT_RGBA, | |
37 DM_IFMT_RGB_PLANE, | |
38 }; | |
39 | |
40 | |
1285
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
41 enum |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
42 { |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
43 DM_ERRMODE_FAIL = 0, |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
44 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
|
45 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
|
46 }; |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
47 |
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
48 |
1286 | 49 // Bitmapped image struct |
435 | 50 typedef struct |
51 { | |
1286 | 52 int format; // one of types specified by DM_IFMT_* |
53 int width, height; | |
54 int pitch; // bytes per scanline | |
55 int bpp; // bits per pixel | |
56 | |
57 int ncolors; // number of colors in palette, if any | |
58 int ctransp; // transparency color index | |
59 BOOL constpal; // is the palette a const? | |
60 DMColor *pal; // pointer to palette struct, NULL if no palette | |
61 | |
929
e1378398be0f
Add size field for allocated data size in DMImage.
Matti Hamalainen <ccr@tnsp.org>
parents:
902
diff
changeset
|
62 size_t size; |
435 | 63 Uint8 *data; |
64 } DMImage; | |
65 | |
66 | |
67 typedef struct | |
68 { | |
1288 | 69 int format; |
70 int scaleX, scaleY; | |
71 int nplanes, bpp; | |
435 | 72 BOOL interleave, paletted; |
1290
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
73 } DMImageConvSpec; |
435 | 74 |
75 | |
76 typedef struct | |
77 { | |
78 char *fext; | |
79 char *desc; | |
80 int (*probe)(const Uint8 *buf, const size_t len); | |
81 int (*read)(const char *filename, DMImage **pimg); | |
82 int (*readFILE)(FILE *fp, DMImage **pimg); | |
1290
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
83 int (*write)(const char *filename, DMImage *pimg, const DMImageConvSpec *spec); |
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
84 int (*writeFILE)(FILE *fp, DMImage *pimg, const DMImageConvSpec *spec); |
435 | 85 } DMImageFormat; |
86 | |
87 | |
88 // Probe scores | |
89 #define DM_PROBE_SCORE_MAX 1000 | |
90 #define DM_PROBE_SCORE_GOOD 750 | |
91 #define DM_PROBE_SCORE_AVG 500 | |
92 #define DM_PROBE_SCORE_MAYBE 250 | |
93 #define DM_PROBE_SCORE_FALSE 0 | |
94 | |
95 | |
96 extern DMImageFormat dmImageFormatList[IMGFMT_LAST]; | |
1285
e4bda4909d72
Make libgfx error mode a global variable, at least for now.
Matti Hamalainen <ccr@tnsp.org>
parents:
971
diff
changeset
|
97 extern int dmGFXErrorMode; |
435 | 98 |
99 | |
1286 | 100 DMImage * dmImageAlloc(const int width, const int height, const int format, const int bpp); |
435 | 101 void dmImageFree(DMImage *img); |
1286 | 102 int dmImageGetBytesPerPixel(const int format); |
435 | 103 int dmImageProbeGeneric(const Uint8 *buf, const size_t len, DMImageFormat **fmt, int *index); |
104 | |
487
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
105 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, BOOL alpha); |
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
106 |
435 | 107 |
1290
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
108 int dmWriteImageData(DMImage *img, void *cbdata, int (*writeRowCB)(void *, Uint8 *, size_t), const DMImageConvSpec *spec); |
435 | 109 |
462 | 110 int dmWriteIFFMasterRAWPalette(FILE *fp, DMImage *img, int ncolors, const char *indent, const char *type); |
1290
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
111 int dmWriteRAWImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec); |
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
112 int dmWriteRAWImage(const char *filename, DMImage *img, const DMImageConvSpec *spec); |
435 | 113 |
1290
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
114 int dmWritePPMImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec); |
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
115 int dmWritePPMImage(const char *filename, DMImage *img, const DMImageConvSpec *spec); |
435 | 116 |
117 #ifdef DM_USE_LIBPNG | |
1290
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
118 int dmWritePNGImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec); |
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
119 int dmWritePNGImage(const char *filename, DMImage *img, const DMImageConvSpec *spec); |
435 | 120 #endif |
121 | |
1290
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
122 int dmWritePCXImageFILE(FILE *fp, DMImage *img, const DMImageConvSpec *spec); |
e7dc9bb9777e
Rename struct DMImageSpec to DMImageConvSpec.
Matti Hamalainen <ccr@tnsp.org>
parents:
1288
diff
changeset
|
123 int dmWritePCXImage(const char *filename, DMImage *img, const DMImageConvSpec *spec); |
435 | 124 int dmReadPCXImageFILE(FILE *fp, DMImage **pimg); |
125 int dmReadPCXImage(const char *filename, DMImage **pimg); | |
126 | |
127 | |
128 #ifdef __cplusplus | |
129 } | |
130 #endif | |
131 | |
132 #endif // LIBMGFX_H |