Mercurial > hg > dmlib
annotate libgfx.h @ 487:b89598501cec
Move dmCompareColor() to libgfx.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 12 Nov 2012 17:21:33 +0200 |
parents | ab401a5087f9 |
children | d400e32b62d9 |
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" | |
12 #include "dmfile.h" | |
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, |
435 | 25 IMGFMT_ARAW, |
26 | |
27 IMGFMT_LAST | |
28 }; | |
29 | |
30 | |
31 enum | |
32 { | |
33 DM_IFMT_PALETTE, | |
34 DM_IFMT_RGB, | |
35 DM_IFMT_RGBA, | |
36 DM_IFMT_RGB_PLANE, | |
37 }; | |
38 | |
39 | |
40 // RGBx color struct | |
41 typedef struct | |
42 { | |
460
0af039b6c0ae
Improve transparent color handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
443
diff
changeset
|
43 Uint8 r, g, b, a; |
435 | 44 } DMColor; |
45 | |
46 | |
47 // Bitmapped image struct (can be one of types specified by DM_IFMT_*) | |
48 typedef struct | |
49 { | |
50 int width, height, pitch; | |
51 BOOL constpal; | |
460
0af039b6c0ae
Improve transparent color handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
443
diff
changeset
|
52 int ncolors, ctransp; |
435 | 53 DMColor *pal; |
54 Uint8 *data; | |
55 } DMImage; | |
56 | |
57 | |
58 typedef struct | |
59 { | |
60 int scale, nplanes, format; | |
61 BOOL interleave, paletted; | |
62 } DMImageSpec; | |
63 | |
64 | |
65 typedef struct | |
66 { | |
67 char *fext; | |
68 char *desc; | |
69 int (*probe)(const Uint8 *buf, const size_t len); | |
70 int (*read)(const char *filename, DMImage **pimg); | |
71 int (*readFILE)(FILE *fp, DMImage **pimg); | |
72 int (*write)(const char *filename, DMImage *pimg, DMImageSpec *spec); | |
73 int (*writeFILE)(FILE *fp, DMImage *pimg, DMImageSpec *spec); | |
74 } DMImageFormat; | |
75 | |
76 | |
77 // Probe scores | |
78 #define DM_PROBE_SCORE_MAX 1000 | |
79 #define DM_PROBE_SCORE_GOOD 750 | |
80 #define DM_PROBE_SCORE_AVG 500 | |
81 #define DM_PROBE_SCORE_MAYBE 250 | |
82 #define DM_PROBE_SCORE_FALSE 0 | |
83 | |
84 | |
85 extern DMImageFormat dmImageFormatList[IMGFMT_LAST]; | |
86 | |
87 | |
88 DMImage * dmImageAlloc(int width, int height); | |
89 void dmImageFree(DMImage *img); | |
90 int dmImageGetBytesPerPixel(int format); | |
91 int dmImageProbeGeneric(const Uint8 *buf, const size_t len, DMImageFormat **fmt, int *index); | |
92 | |
487
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
93 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, BOOL alpha); |
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
94 |
435 | 95 |
96 int dmWriteImageData(DMImage *img, void *cbdata, BOOL (*writeRowCB)(void *, Uint8 *, size_t), const DMImageSpec *spec); | |
97 | |
462 | 98 int dmWriteIFFMasterRAWPalette(FILE *fp, DMImage *img, int ncolors, const char *indent, const char *type); |
435 | 99 int dmWriteIFFMasterRAWImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); |
100 int dmWriteIFFMasterRAWImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
101 | |
102 int dmWritePPMImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
103 int dmWritePPMImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
104 | |
105 #ifdef DM_USE_LIBPNG | |
106 int dmWritePNGImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
107 int dmWritePNGImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
108 #endif | |
109 | |
110 int dmWritePCXImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
111 int dmWritePCXImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
112 int dmReadPCXImageFILE(FILE *fp, DMImage **pimg); | |
113 int dmReadPCXImage(const char *filename, DMImage **pimg); | |
114 | |
115 | |
116 #ifdef __cplusplus | |
117 } | |
118 #endif | |
119 | |
120 #endif // LIBMGFX_H |