comparison tools/libgfx.h @ 1609:c29adf5ce240

Convert libgfx file format routines to use DMResource instead of stdio FILE. Also do necessary changes in gfxconv due to these API changes.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 14 May 2018 12:42:24 +0300
parents 3b613fcbf3ff
children 36d073c45327
comparison
equal deleted inserted replaced
1608:7f9fe2a9a87e 1609:c29adf5ce240
7 */ 7 */
8 #ifndef LIBMGFX_H 8 #ifndef LIBMGFX_H
9 #define LIBMGFX_H 1 9 #define LIBMGFX_H 1
10 10
11 #include "dmlib.h" 11 #include "dmlib.h"
12 #include "dmres.h"
12 13
13 14
14 #ifdef __cplusplus 15 #ifdef __cplusplus
15 extern "C" { 16 extern "C" {
16 #endif 17 #endif
64 DM_FMT_RD = 0x0002, 65 DM_FMT_RD = 0x0002,
65 DM_FMT_RDWR = (DM_FMT_RD | DM_FMT_WR), 66 DM_FMT_RDWR = (DM_FMT_RD | DM_FMT_WR),
66 }; 67 };
67 68
68 69
69 // Bitmapped image struct 70 // Bitmapped image struct
70 typedef struct 71 typedef struct
71 { 72 {
72 int format; // one of types specified by DM_IFMT_* 73 int format; // one of types specified by DM_IFMT_*
73 int width, height; 74 int width, height;
74 int pitch; // bytes per scanline 75 int pitch; // bytes per scanline
97 { 98 {
98 char *fext; 99 char *fext;
99 char *desc; 100 char *desc;
100 int (*probe)(const Uint8 *buf, const size_t len); 101 int (*probe)(const Uint8 *buf, const size_t len);
101 int (*read)(const char *filename, DMImage **pimg); 102 int (*read)(const char *filename, DMImage **pimg);
102 int (*readFILE)(FILE *fp, DMImage **pimg); 103 int (*readFILE)(DMResource *fp, DMImage **pimg);
103 int (*write)(const char *filename, const DMImage *pimg, const DMImageConvSpec *spec); 104 int (*write)(const char *filename, const DMImage *pimg, const DMImageConvSpec *spec);
104 int (*writeFILE)(FILE *fp, const DMImage *pimg, const DMImageConvSpec *spec); 105 int (*writeFILE)(DMResource *fp, const DMImage *pimg, const DMImageConvSpec *spec);
105 } DMImageFormat; 106 } DMImageFormat;
106 107
107 108
108 extern DMImageFormat dmImageFormatList[DM_IMGFMT_LAST]; 109 extern DMImageFormat dmImageFormatList[DM_IMGFMT_LAST];
109 extern int dmGFXErrorMode; 110 extern int dmGFXErrorMode;
117 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, BOOL alpha); 118 BOOL dmCompareColor(const DMColor *c1, const DMColor *c2, BOOL alpha);
118 119
119 120
120 int dmWriteImageData(const DMImage *img, void *cbdata, int (*writeRowCB)(void *, const Uint8 *, const size_t), const DMImageConvSpec *spec); 121 int dmWriteImageData(const DMImage *img, void *cbdata, int (*writeRowCB)(void *, const Uint8 *, const size_t), const DMImageConvSpec *spec);
121 122
122 int dmWriteIFFMasterRAWPalette(FILE *fp, const DMImage *img, int ncolors, const char *indent, const char *type); 123 int dmWriteRAWImageFILE(DMResource *fp, const DMImage *img, const DMImageConvSpec *spec);
123 int dmWriteRAWImageFILE(FILE *fp, const DMImage *img, const DMImageConvSpec *spec);
124 int dmWriteRAWImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec); 124 int dmWriteRAWImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec);
125 125
126 int dmWritePPMImageFILE(FILE *fp, const DMImage *img, const DMImageConvSpec *spec); 126 int dmWritePPMImageFILE(DMResource *fp, const DMImage *img, const DMImageConvSpec *spec);
127 int dmWritePPMImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec); 127 int dmWritePPMImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec);
128 128
129 #ifdef DM_USE_LIBPNG 129 #ifdef DM_USE_LIBPNG
130 int dmWritePNGImageFILE(FILE *fp, const DMImage *img, const DMImageConvSpec *spec); 130 int dmWritePNGImageFILE(DMResource *fp, const DMImage *img, const DMImageConvSpec *spec);
131 int dmWritePNGImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec); 131 int dmWritePNGImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec);
132 #endif 132 #endif
133 133
134 int dmReadILBMImageFILE(FILE *fp, DMImage **pimg); 134 int dmReadILBMImageFILE(DMResource *fp, DMImage **pimg);
135 int dmReadILBMImage(const char *filename, DMImage **pimg); 135 int dmReadILBMImage(const char *filename, DMImage **pimg);
136 136
137 int dmWritePCXImageFILE(FILE *fp, const DMImage *img, const DMImageConvSpec *spec); 137 int dmWritePCXImageFILE(DMResource *fp, const DMImage *img, const DMImageConvSpec *spec);
138 int dmWritePCXImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec); 138 int dmWritePCXImage(const char *filename, const DMImage *img, const DMImageConvSpec *spec);
139 int dmReadPCXImageFILE(FILE *fp, DMImage **pimg); 139 int dmReadPCXImageFILE(DMResource *fp, DMImage **pimg);
140 int dmReadPCXImage(const char *filename, DMImage **pimg); 140 int dmReadPCXImage(const char *filename, DMImage **pimg);
141 141
142 142
143 typedef struct _DMBitStreamContext 143 typedef struct _DMBitStreamContext
144 { 144 {
151 151
152 152
153 void dmInitBitStreamContext(DMBitStreamContext *ctx); 153 void dmInitBitStreamContext(DMBitStreamContext *ctx);
154 int dmFlushBitStream(DMBitStreamContext *ctx); 154 int dmFlushBitStream(DMBitStreamContext *ctx);
155 BOOL dmPutBits(DMBitStreamContext *ctx, const int val, const int n); 155 BOOL dmPutBits(DMBitStreamContext *ctx, const int val, const int n);
156 int dmInitBitStreamFILE(DMBitStreamContext *ctx, FILE *fp); 156 int dmInitBitStreamFILE(DMBitStreamContext *ctx, DMResource *fp);
157 157
158 158
159 159
160 #ifdef __cplusplus 160 #ifdef __cplusplus
161 } 161 }