comparison libgfx.c @ 462:ab401a5087f9

Improve ARAW output.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 04 Nov 2012 16:09:07 +0200
parents c7a3aacbd55e
children 358776103ceb
comparison
equal deleted inserted replaced
461:c7a3aacbd55e 462:ab401a5087f9
208 } 208 }
209 209
210 210
211 #define DMCOL(x) (((x) >> 4) & 0xf) 211 #define DMCOL(x) (((x) >> 4) & 0xf)
212 212
213 int dmWriteIFFMasterRAWPalette(const char *filename, DMImage *img, int ncolors) 213 int dmWriteIFFMasterRAWPalette(FILE *fp, DMImage *img, int ncolors,
214 { 214 const char *indent, const char *type)
215 FILE *fp; 215 {
216 int i; 216 int i;
217
218 if ((fp = fopen(filename, "w")) == NULL)
219 {
220 dmError("IFFMasterRAW: Could not open file '%s' for writing.\n", filename);
221 return -15;
222 }
223 217
224 for (i = 0; i < ncolors; i++) 218 for (i = 0; i < ncolors; i++)
225 { 219 {
226 int color; 220 int color;
227 if (i < img->ncolors) 221 if (i < img->ncolors)
231 (DMCOL(img->pal[i].b)); 225 (DMCOL(img->pal[i].b));
232 } 226 }
233 else 227 else
234 color = 0; 228 color = 0;
235 229
236 fprintf(fp, "\tdc.w $%04X\n", color); 230 fprintf(fp, "%s%s $%04X\n",
237 } 231 indent != NULL ? indent : "\t",
238 232 type != NULL ? type : "dw.b",
239 fclose(fp); 233 color);
240 return 0; 234 }
235
236 return DMERR_OK;
241 } 237 }
242 238
243 239
244 int dmWriteIFFMasterRAWImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec) 240 int dmWriteIFFMasterRAWImageFILE(FILE *fp, DMImage *img, DMImageSpec *spec)
245 { 241 {