comparison tools/gfxconv.c @ 1543:416d7b3ba3b2

Rename libgfx IMGFMT_* constants to DM_IMGFMT_*.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 12 May 2018 17:48:56 +0300
parents 776aa43b2c57
children 3b613fcbf3ff
comparison
equal deleted inserted replaced
1542:69fa95707e65 1543:416d7b3ba3b2
65 "ANSI colored text", "ansi", FALSE, TRUE, 65 "ANSI colored text", "ansi", FALSE, TRUE,
66 FFMT_ANSI , 0, 66 FFMT_ANSI , 0,
67 }, 67 },
68 { 68 {
69 "PNG image file", "png", TRUE, TRUE, 69 "PNG image file", "png", TRUE, TRUE,
70 FFMT_IMAGE , IMGFMT_PNG, 70 FFMT_IMAGE , DM_IMGFMT_PNG,
71 }, 71 },
72 { 72 {
73 "PPM image file", "ppm", FALSE, TRUE, 73 "PPM image file", "ppm", FALSE, TRUE,
74 FFMT_IMAGE , IMGFMT_PPM, 74 FFMT_IMAGE , DM_IMGFMT_PPM,
75 }, 75 },
76 { 76 {
77 "PCX image file", "pcx", TRUE, TRUE, 77 "PCX image file", "pcx", TRUE, TRUE,
78 FFMT_IMAGE , IMGFMT_PCX, 78 FFMT_IMAGE , DM_IMGFMT_PCX,
79 }, 79 },
80 { 80 {
81 "IFF ILBM file", "lbm", TRUE, FALSE, 81 "IFF ILBM file", "lbm", TRUE, FALSE,
82 FFMT_IMAGE , IMGFMT_ILBM, 82 FFMT_IMAGE , DM_IMGFMT_ILBM,
83 }, 83 },
84 { 84 {
85 "Bitplaned RAW (intl/non-intl) image file", "raw", FALSE, TRUE, 85 "Bitplaned RAW (intl/non-intl) image file", "raw", FALSE, TRUE,
86 FFMT_IMAGE , IMGFMT_RAW, 86 FFMT_IMAGE , DM_IMGFMT_RAW,
87 }, 87 },
88 { 88 {
89 "IFFMaster RAW image file", "araw", FALSE, TRUE, 89 "IFFMaster RAW image file", "araw", FALSE, TRUE,
90 FFMT_IMAGE , IMGFMT_ARAW, 90 FFMT_IMAGE , DM_IMGFMT_ARAW,
91 }, 91 },
92 92
93 { 93 {
94 "C64 bitmap image file", NULL, TRUE, TRUE, 94 "C64 bitmap image file", NULL, TRUE, TRUE,
95 FFMT_BITMAP , -1, 95 FFMT_BITMAP , -1,
120 char *optInFilename = NULL, 120 char *optInFilename = NULL,
121 *optOutFilename = NULL; 121 *optOutFilename = NULL;
122 122
123 int optInFormat = FFMT_AUTO, 123 int optInFormat = FFMT_AUTO,
124 optOutFormat = FFMT_ASCII, 124 optOutFormat = FFMT_ASCII,
125 optInSubFormat = IMGFMT_PNG, 125 optInSubFormat = DM_IMGFMT_PNG,
126 optOutSubFormat = IMGFMT_PNG, 126 optOutSubFormat = DM_IMGFMT_PNG,
127 optItemCount = -1, 127 optItemCount = -1,
128 optPlanedWidth = 1, 128 optPlanedWidth = 1,
129 optForcedFormat = -1; 129 optForcedFormat = -1;
130 unsigned int optInSkip = 0; 130 unsigned int optInSkip = 0;
131 131
1152 } 1152 }
1153 1153
1154 switch (iformat) 1154 switch (iformat)
1155 { 1155 {
1156 #ifdef DM_USE_LIBPNG 1156 #ifdef DM_USE_LIBPNG
1157 case IMGFMT_PNG: 1157 case DM_IMGFMT_PNG:
1158 spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGBA; 1158 spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGBA;
1159 dmOutputImageBitFormat(spec->format, info); 1159 dmOutputImageBitFormat(spec->format, info);
1160 res = dmWritePNGImage(filename, image, spec); 1160 res = dmWritePNGImage(filename, image, spec);
1161 break; 1161 break;
1162 #endif 1162 #endif
1163 1163
1164 case IMGFMT_PPM: 1164 case DM_IMGFMT_PPM:
1165 spec->format = DM_IFMT_RGB; 1165 spec->format = DM_IFMT_RGB;
1166 dmOutputImageBitFormat(spec->format, info); 1166 dmOutputImageBitFormat(spec->format, info);
1167 res = dmWritePPMImage(filename, image, spec); 1167 res = dmWritePPMImage(filename, image, spec);
1168 break; 1168 break;
1169 1169
1170 case IMGFMT_PCX: 1170 case DM_IMGFMT_PCX:
1171 spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGB; 1171 spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGB;
1172 dmOutputImageBitFormat(spec->format, info); 1172 dmOutputImageBitFormat(spec->format, info);
1173 res = dmWritePCXImage(filename, image, spec); 1173 res = dmWritePCXImage(filename, image, spec);
1174 break; 1174 break;
1175 1175
1176 case IMGFMT_RAW: 1176 case DM_IMGFMT_RAW:
1177 case IMGFMT_ARAW: 1177 case DM_IMGFMT_ARAW:
1178 { 1178 {
1179 // Open data file for writing 1179 // Open data file for writing
1180 FILE *fp; 1180 FILE *fp;
1181 char * dataFilename = dm_strdup_fext(filename, "%s.inc"); 1181 char * dataFilename = dm_strdup_fext(filename, "%s.inc");
1182 if ((fp = fopen(dataFilename, "w")) == NULL) 1182 if ((fp = fopen(dataFilename, "w")) == NULL)
1200 palID[i] = tolower(palID[i]); 1200 palID[i] = tolower(palID[i]);
1201 else 1201 else
1202 palID[i] = '_'; 1202 palID[i] = '_';
1203 } 1203 }
1204 1204
1205 if (iformat == IMGFMT_ARAW) 1205 if (iformat == DM_IMGFMT_ARAW)
1206 { 1206 {
1207 fprintf(fp, 1207 fprintf(fp,
1208 "%s_width: dw.w %d\n" 1208 "%s_width: dw.w %d\n"
1209 "%s_height: dw.w %d\n" 1209 "%s_height: dw.w %d\n"
1210 "%s_nplanes: dw.w %d\n" 1210 "%s_nplanes: dw.w %d\n"
1627 if (!dmArgsProcess(argc, argv, optList, optListN, 1627 if (!dmArgsProcess(argc, argv, optList, optListN,
1628 argHandleOpt, argHandleFile, OPTH_BAILOUT)) 1628 argHandleOpt, argHandleFile, OPTH_BAILOUT))
1629 exit(1); 1629 exit(1);
1630 1630
1631 #ifndef DM_USE_LIBPNG 1631 #ifndef DM_USE_LIBPNG
1632 if (optOutFormat == IMGFMT_PNG) 1632 if (optOutFormat == DM_IMGFMT_PNG)
1633 { 1633 {
1634 dmErrorMsg("PNG output format support not compiled in, sorry.\n"); 1634 dmErrorMsg("PNG output format support not compiled in, sorry.\n");
1635 goto error; 1635 goto error;
1636 } 1636 }
1637 #endif 1637 #endif