Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 1303:be30466fbc47
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 19 Aug 2017 11:54:20 +0300 |
parents | 1dce9e5f4a2f |
children | a8850642d0d2 |
comparison
equal
deleted
inserted
replaced
1302:38614c07c2e2 | 1303:be30466fbc47 |
---|---|
1073 dmFree(buf); | 1073 dmFree(buf); |
1074 return res; | 1074 return res; |
1075 } | 1075 } |
1076 | 1076 |
1077 | 1077 |
1078 void dmOutputImageBitFormat(const int format, const BOOL info) | |
1079 { | |
1080 if (info) | |
1081 { | |
1082 char *str; | |
1083 switch (format) | |
1084 { | |
1085 case DM_IFMT_PALETTE : str = "Indexed 8bpp"; break; | |
1086 case DM_IFMT_RGB : str = "24bit RGB"; break; | |
1087 case DM_IFMT_RGBA : str = "32bit RGBA"; break; | |
1088 default : str = "???"; break; | |
1089 } | |
1090 dmMsg(2, "%s output.\n", str); | |
1091 } | |
1092 } | |
1093 | |
1094 | |
1078 int dmWriteImage(const char *filename, DMImage *image, DMImageConvSpec *spec, int iformat, BOOL info) | 1095 int dmWriteImage(const char *filename, DMImage *image, DMImageConvSpec *spec, int iformat, BOOL info) |
1079 { | 1096 { |
1080 if (info) | 1097 if (info) |
1081 { | 1098 { |
1082 dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d x %d]\n", | 1099 dmMsg(1, "Outputting %s image %d x %d -> %d x %d [%d x %d]\n", |
1096 | 1113 |
1097 switch (iformat) | 1114 switch (iformat) |
1098 { | 1115 { |
1099 #ifdef DM_USE_LIBPNG | 1116 #ifdef DM_USE_LIBPNG |
1100 case IMGFMT_PNG: | 1117 case IMGFMT_PNG: |
1101 if (info) dmMsg(2, "%s output.\n", spec->paletted ? "Indexed 8bpp" : "32bit RGBA"); | |
1102 spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGBA; | 1118 spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGBA; |
1119 dmOutputImageBitFormat(spec->format, info); | |
1103 return dmWritePNGImage(filename, image, spec); | 1120 return dmWritePNGImage(filename, image, spec); |
1104 #endif | 1121 #endif |
1105 | 1122 |
1106 case IMGFMT_PPM: | 1123 case IMGFMT_PPM: |
1107 if (info) dmMsg(2, "24bit RGB output.\n"); | |
1108 spec->format = DM_IFMT_RGB; | 1124 spec->format = DM_IFMT_RGB; |
1125 dmOutputImageBitFormat(spec->format, info); | |
1109 return dmWritePPMImage(filename, image, spec); | 1126 return dmWritePPMImage(filename, image, spec); |
1110 | 1127 |
1111 case IMGFMT_PCX: | 1128 case IMGFMT_PCX: |
1112 if (info) dmMsg(2, "%s output.\n", spec->paletted ? "Indexed 8bpp" : "24bit RGB"); | 1129 spec->format = spec->paletted ? DM_IFMT_PALETTE : DM_IFMT_RGB; |
1130 dmOutputImageBitFormat(spec->format, info); | |
1113 return dmWritePCXImage(filename, image, spec); | 1131 return dmWritePCXImage(filename, image, spec); |
1114 | 1132 |
1115 case IMGFMT_RAW: | 1133 case IMGFMT_RAW: |
1116 case IMGFMT_ARAW: | 1134 case IMGFMT_ARAW: |
1117 { | 1135 { |