Mercurial > hg > dmlib
comparison gfxconv.c @ 534:fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 22 Nov 2012 21:09:15 +0200 |
parents | 5b37a2e427b7 |
children | e74a0e027681 |
comparison
equal
deleted
inserted
replaced
533:91e2d0d74e2f | 534:fbfdc9e4fe2b |
---|---|
77 "IFFMaster RAW image file", "araw", FALSE, TRUE, | 77 "IFFMaster RAW image file", "araw", FALSE, TRUE, |
78 FFMT_IMAGE , IMGFMT_ARAW, | 78 FFMT_IMAGE , IMGFMT_ARAW, |
79 }, | 79 }, |
80 | 80 |
81 { | 81 { |
82 "C64 bitmap image file", NULL, TRUE, FALSE, | 82 "C64 bitmap image file", NULL, TRUE, TRUE, |
83 FFMT_BITMAP , 0, | 83 FFMT_BITMAP , -1, |
84 }, | 84 }, |
85 | 85 |
86 { | 86 { |
87 "C64 character/font data", "chr", TRUE, TRUE, | 87 "C64 character/font data", "chr", TRUE, TRUE, |
88 FFMT_CHAR , 0 | 88 FFMT_CHAR , 0 |
160 | 160 |
161 void argShowFormats() | 161 void argShowFormats() |
162 { | 162 { |
163 int i; | 163 int i; |
164 | 164 |
165 printf("\n" | 165 printf( |
166 "Available input/output formats:\n" | 166 "Available input/output formats:\n" |
167 " EXT | I | O | Description\n" | 167 " Ext | I | O | Description\n" |
168 "------+---+---+--------------------------------\n" | 168 "------+---+---+-----------------------------------------------\n" |
169 ); | 169 ); |
170 | 170 |
171 for (i = 0; i < nconvFormatList; i++) | 171 for (i = 0; i < nconvFormatList; i++) |
172 { | 172 { |
173 DMConvFormat *fmt = &convFormatList[i]; | 173 DMConvFormat *fmt = &convFormatList[i]; |
176 fmt->in ? 'X' : ' ', | 176 fmt->in ? 'X' : ' ', |
177 fmt->out ? 'X' : ' ', | 177 fmt->out ? 'X' : ' ', |
178 fmt->name); | 178 fmt->name); |
179 } | 179 } |
180 | 180 |
181 printf("\nAvailable bitmap formats:\n"); | 181 printf( |
182 "\n" | |
183 "(Not all input->output combinations are actually supported.)\n" | |
184 "\n" | |
185 "Available bitmap formats:\n" | |
186 " Ext | Type | Description\n" | |
187 "------+-----------------+-------------------------------------\n" | |
188 ); | |
189 | |
182 for (i = 0; i < ndmC64ImageFormats; i++) | 190 for (i = 0; i < ndmC64ImageFormats; i++) |
183 { | 191 { |
184 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; | 192 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; |
185 char buf[64]; | 193 char buf[64]; |
186 printf("%3d | %-5s | %-15s | %s\n", | 194 printf("%-5s | %-15s | %s\n", |
187 i, fmt->extension, | 195 fmt->fext, |
188 dmC64GetImageTypeString(buf, sizeof(buf), fmt->type), | 196 dmC64GetImageTypeString(buf, sizeof(buf), fmt->type), |
189 fmt->name); | 197 fmt->name); |
190 } | 198 } |
191 } | 199 } |
192 | 200 |
238 *format = fmt->format; | 246 *format = fmt->format; |
239 *subformat = fmt->subformat; | 247 *subformat = fmt->subformat; |
240 return TRUE; | 248 return TRUE; |
241 } | 249 } |
242 } | 250 } |
251 | |
252 for (i = 0; i < ndmC64ImageFormats; i++) | |
253 { | |
254 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; | |
255 if (fmt->fext != NULL && | |
256 strcasecmp(fext, fmt->fext) == 0) | |
257 { | |
258 *format = FFMT_BITMAP; | |
259 *subformat = i; | |
260 return TRUE; | |
261 } | |
262 } | |
263 | |
243 return FALSE; | 264 return FALSE; |
244 } | 265 } |
245 | 266 |
246 | 267 |
247 static BOOL dmParseMapOptionMapItem(const char *popt, DMMapValue *value, const int nmax, const char *msg) | 268 static BOOL dmParseMapOptionMapItem(const char *popt, DMMapValue *value, const int nmax, const char *msg) |
906 dmFree(used); | 927 dmFree(used); |
907 return DMERR_OK; | 928 return DMERR_OK; |
908 } | 929 } |
909 | 930 |
910 | 931 |
932 int dmWriteBitmap(const char *filename, DMC64Image *image, int iformat) | |
933 { | |
934 return DMERR_OK; | |
935 } | |
936 | |
937 | |
911 int dmWriteImage(const char *filename, DMImage *image, DMImageSpec *spec, int iformat, BOOL info) | 938 int dmWriteImage(const char *filename, DMImage *image, DMImageSpec *spec, int iformat, BOOL info) |
912 { | 939 { |
913 if (info) | 940 if (info) |
914 { | 941 { |
915 dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d]\n", | 942 dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d]\n", |
1175 fclose(outFile); | 1202 fclose(outFile); |
1176 dmFree(buf); | 1203 dmFree(buf); |
1177 return -1; | 1204 return -1; |
1178 } | 1205 } |
1179 | 1206 |
1207 | |
1180 int dmDumpSpritesAndChars(FILE *inFile) | 1208 int dmDumpSpritesAndChars(FILE *inFile) |
1181 { | 1209 { |
1182 int dataOffs, itemCount, outWidth, outWidthPX, outHeight; | 1210 int dataOffs, itemCount, outWidth, outWidthPX, outHeight; |
1183 size_t bufSize; | 1211 size_t bufSize; |
1184 Uint8 *bufData; | 1212 Uint8 *bufData; |
1428 | 1456 |
1429 if (optForcedFormat >= 0) | 1457 if (optForcedFormat >= 0) |
1430 { | 1458 { |
1431 forced = &dmC64ImageFormats[optForcedFormat]; | 1459 forced = &dmC64ImageFormats[optForcedFormat]; |
1432 dmMsg(0,"Forced %s format image, type %d, %s\n", | 1460 dmMsg(0,"Forced %s format image, type %d, %s\n", |
1433 forced->name, forced->type, forced->extension); | 1461 forced->name, forced->type, forced->fext); |
1434 } | 1462 } |
1435 | 1463 |
1436 res = dmC64DecodeBMP(&cimage, dataBuf, dataSize, optInSkip, optInSkip + 2, &cfmt, forced); | 1464 res = dmC64DecodeBMP(&cimage, dataBuf, dataSize, optInSkip, optInSkip + 2, &cfmt, forced); |
1437 if (forced == NULL && cfmt != NULL) | 1465 if (forced == NULL && cfmt != NULL) |
1438 { | 1466 { |
1439 dmMsg(1,"Probed %s format image, type %d, %s\n", | 1467 dmMsg(1,"Probed %s format image, type %d, %s\n", |
1440 cfmt->name, cfmt->type, cfmt->extension); | 1468 cfmt->name, cfmt->type, cfmt->fext); |
1441 } | 1469 } |
1442 | 1470 |
1443 if (res == 0) | 1471 if (res == 0) |
1444 optInFormat = FFMT_BITMAP; | 1472 optInFormat = FFMT_BITMAP; |
1445 } | 1473 } |
1533 } | 1561 } |
1534 | 1562 |
1535 res = dmWriteImage(optOutFilename, outImage, &optSpec, optOutSubFormat, TRUE); | 1563 res = dmWriteImage(optOutFilename, outImage, &optSpec, optOutSubFormat, TRUE); |
1536 break; | 1564 break; |
1537 | 1565 |
1566 | |
1567 case FFMT_BITMAP: | |
1568 res = dmWriteBitmap(optOutFilename, &cimage, optOutSubFormat); | |
1569 break; | |
1570 | |
1538 default: | 1571 default: |
1539 dmError("Unsupported output format for bitmap/image conversion.\n"); | 1572 dmError("Unsupported output format for bitmap/image conversion.\n"); |
1540 break; | 1573 break; |
1541 } | 1574 } |
1542 | 1575 |