Mercurial > hg > dmlib
annotate src/libgfx.h @ 902:c6c480e8e1c8
Add separate X and Y scaling to gfxconv and libgfx outputters.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 23 Feb 2015 20:45:31 +0200 |
parents | 1e5cf1144f36 |
children | e1378398be0f |
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, |
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 | |
41 // RGBx color struct | |
42 typedef struct | |
43 { | |
460
0af039b6c0ae
Improve transparent color handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
443
diff
changeset
|
44 Uint8 r, g, b, a; |
435 | 45 } DMColor; |
46 | |
47 | |
48 // Bitmapped image struct (can be one of types specified by DM_IFMT_*) | |
49 typedef struct | |
50 { | |
51 int width, height, pitch; | |
52 BOOL constpal; | |
460
0af039b6c0ae
Improve transparent color handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
443
diff
changeset
|
53 int ncolors, ctransp; |
435 | 54 DMColor *pal; |
55 Uint8 *data; | |
56 } DMImage; | |
57 | |
58 | |
59 typedef struct | |
60 { | |
902
c6c480e8e1c8
Add separate X and Y scaling to gfxconv and libgfx outputters.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
61 int scaleX, scaleY, nplanes, format; |
435 | 62 BOOL interleave, paletted; |
63 } DMImageSpec; | |
64 | |
65 | |
66 typedef struct | |
67 { | |
68 char *fext; | |
69 char *desc; | |
70 int (*probe)(const Uint8 *buf, const size_t len); | |
71 int (*read)(const char *filename, DMImage **pimg); | |
72 int (*readFILE)(FILE *fp, DMImage **pimg); | |
73 int (*write)(const char *filename, DMImage *pimg, DMImageSpec *spec); | |
74 int (*writeFILE)(FILE *fp, DMImage *pimg, DMImageSpec *spec); | |
75 } DMImageFormat; | |
76 | |
77 | |
78 // Probe scores | |
79 #define DM_PROBE_SCORE_MAX 1000 | |
80 #define DM_PROBE_SCORE_GOOD 750 | |
81 #define DM_PROBE_SCORE_AVG 500 | |
82 #define DM_PROBE_SCORE_MAYBE 250 | |
83 #define DM_PROBE_SCORE_FALSE 0 | |
84 | |
85 | |
86 extern DMImageFormat dmImageFormatList[IMGFMT_LAST]; | |
87 | |
88 | |
89 DMImage * dmImageAlloc(int width, int height); | |
90 void dmImageFree(DMImage *img); | |
91 int dmImageGetBytesPerPixel(int format); | |
92 int dmImageProbeGeneric(const Uint8 *buf, const size_t len, DMImageFormat **fmt, int *index); | |
93 | |
487
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
94 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, BOOL alpha); |
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
95 |
435 | 96 |
808
f8126fa1df9b
Use dmlib error code return value in cases where a plain boolean was used
Matti Hamalainen <ccr@tnsp.org>
parents:
566
diff
changeset
|
97 int dmWriteImageData(DMImage *img, void *cbdata, int (*writeRowCB)(void *, Uint8 *, size_t), const DMImageSpec *spec); |
435 | 98 |
462 | 99 int dmWriteIFFMasterRAWPalette(FILE *fp, DMImage *img, int ncolors, const char *indent, const char *type); |
566
d400e32b62d9
Add a slightly different raw output format.
Matti Hamalainen <ccr@tnsp.org>
parents:
487
diff
changeset
|
100 int dmWriteRAWImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); |
d400e32b62d9
Add a slightly different raw output format.
Matti Hamalainen <ccr@tnsp.org>
parents:
487
diff
changeset
|
101 int dmWriteRAWImage(const char *filename, DMImage *img, DMImageSpec *spec); |
435 | 102 |
103 int dmWritePPMImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
104 int dmWritePPMImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
105 | |
106 #ifdef DM_USE_LIBPNG | |
107 int dmWritePNGImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
108 int dmWritePNGImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
109 #endif | |
110 | |
111 int dmWritePCXImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
112 int dmWritePCXImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
113 int dmReadPCXImageFILE(FILE *fp, DMImage **pimg); | |
114 int dmReadPCXImage(const char *filename, DMImage **pimg); | |
115 | |
116 | |
117 #ifdef __cplusplus | |
118 } | |
119 #endif | |
120 | |
121 #endif // LIBMGFX_H |