Mercurial > hg > dmlib
annotate src/libgfx.h @ 971:f654435df15e
Rename DMRGBA32 struct to DMColor and remove the original redundant DMColor
struct definition.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 27 Feb 2015 06:10:16 +0200 |
parents | 5ac8f5513978 |
children | e4bda4909d72 |
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 | |
41 // Bitmapped image struct (can be one of types specified by DM_IFMT_*) | |
42 typedef struct | |
43 { | |
44 int width, height, pitch; | |
45 BOOL constpal; | |
460
0af039b6c0ae
Improve transparent color handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
443
diff
changeset
|
46 int ncolors, ctransp; |
435 | 47 DMColor *pal; |
929
e1378398be0f
Add size field for allocated data size in DMImage.
Matti Hamalainen <ccr@tnsp.org>
parents:
902
diff
changeset
|
48 size_t size; |
435 | 49 Uint8 *data; |
50 } DMImage; | |
51 | |
52 | |
53 typedef struct | |
54 { | |
902
c6c480e8e1c8
Add separate X and Y scaling to gfxconv and libgfx outputters.
Matti Hamalainen <ccr@tnsp.org>
parents:
812
diff
changeset
|
55 int scaleX, scaleY, nplanes, format; |
435 | 56 BOOL interleave, paletted; |
57 } DMImageSpec; | |
58 | |
59 | |
60 typedef struct | |
61 { | |
62 char *fext; | |
63 char *desc; | |
64 int (*probe)(const Uint8 *buf, const size_t len); | |
65 int (*read)(const char *filename, DMImage **pimg); | |
66 int (*readFILE)(FILE *fp, DMImage **pimg); | |
67 int (*write)(const char *filename, DMImage *pimg, DMImageSpec *spec); | |
68 int (*writeFILE)(FILE *fp, DMImage *pimg, DMImageSpec *spec); | |
69 } DMImageFormat; | |
70 | |
71 | |
72 // Probe scores | |
73 #define DM_PROBE_SCORE_MAX 1000 | |
74 #define DM_PROBE_SCORE_GOOD 750 | |
75 #define DM_PROBE_SCORE_AVG 500 | |
76 #define DM_PROBE_SCORE_MAYBE 250 | |
77 #define DM_PROBE_SCORE_FALSE 0 | |
78 | |
79 | |
80 extern DMImageFormat dmImageFormatList[IMGFMT_LAST]; | |
81 | |
82 | |
83 DMImage * dmImageAlloc(int width, int height); | |
84 void dmImageFree(DMImage *img); | |
85 int dmImageGetBytesPerPixel(int format); | |
86 int dmImageProbeGeneric(const Uint8 *buf, const size_t len, DMImageFormat **fmt, int *index); | |
87 | |
487
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
88 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, BOOL alpha); |
b89598501cec
Move dmCompareColor() to libgfx.
Matti Hamalainen <ccr@tnsp.org>
parents:
462
diff
changeset
|
89 |
435 | 90 |
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
|
91 int dmWriteImageData(DMImage *img, void *cbdata, int (*writeRowCB)(void *, Uint8 *, size_t), const DMImageSpec *spec); |
435 | 92 |
462 | 93 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
|
94 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
|
95 int dmWriteRAWImage(const char *filename, DMImage *img, DMImageSpec *spec); |
435 | 96 |
97 int dmWritePPMImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
98 int dmWritePPMImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
99 | |
100 #ifdef DM_USE_LIBPNG | |
101 int dmWritePNGImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
102 int dmWritePNGImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
103 #endif | |
104 | |
105 int dmWritePCXImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec); | |
106 int dmWritePCXImage(const char *filename, DMImage *img, DMImageSpec *spec); | |
107 int dmReadPCXImageFILE(FILE *fp, DMImage **pimg); | |
108 int dmReadPCXImage(const char *filename, DMImage **pimg); | |
109 | |
110 | |
111 #ifdef __cplusplus | |
112 } | |
113 #endif | |
114 | |
115 #endif // LIBMGFX_H |