Mercurial > hg > dmlib
comparison tools/lib64gfx.c @ 2204:cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
that do not strictly belong.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 14 Jun 2019 03:24:24 +0300 |
parents | b259312ddb59 |
children | 7694b5c8edc1 |
comparison
equal
deleted
inserted
replaced
2203:b259312ddb59 | 2204:cbac4912992c |
---|---|
84 }, | 84 }, |
85 }, | 85 }, |
86 }; | 86 }; |
87 | 87 |
88 const int ndmC64DefaultPalettes = sizeof(dmC64DefaultPalettes) / sizeof(dmC64DefaultPalettes[0]); | 88 const int ndmC64DefaultPalettes = sizeof(dmC64DefaultPalettes) / sizeof(dmC64DefaultPalettes[0]); |
89 | |
90 | |
91 char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng) | |
92 { | |
93 static const char *fmtModesShort[] = { "*", "HiR", "MC", "ECM" }; | |
94 static const char *fmtModesLong[] = { "*", "HiRes", "MultiColor", "Extended Color Mode" }; | |
95 const char *fmtStr; | |
96 size_t nfmt = type & D64_FMT_MODE_MASK; | |
97 | |
98 if (nfmt < sizeof(fmtModesShort) / sizeof(fmtModesShort[0])) | |
99 fmtStr = lng ? fmtModesLong[nfmt] : fmtModesShort[nfmt]; | |
100 else | |
101 fmtStr = lng ? "ERROR" : "ERR"; | |
102 | |
103 snprintf(buf, len, | |
104 "%s %s%s%s", | |
105 fmtStr, | |
106 (type & D64_FMT_ILACE) ? (lng ? "Interlaced " : "ILace ") : "", | |
107 (type & D64_FMT_FLI) ? "FLI " : "", | |
108 (type & D64_FMT_CHAR) ? "CHAR" : "" | |
109 ); | |
110 | |
111 return buf; | |
112 } | |
113 | |
114 | |
115 void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt, const char *indent) | |
116 { | |
117 char typeStr[64]; | |
118 | |
119 if (fmt != NULL) | |
120 { | |
121 fprintf(fh, | |
122 "%sFormat : %s [%s]\n", | |
123 indent, fmt->name, fmt->fext); | |
124 } | |
125 | |
126 if (img != NULL) | |
127 { | |
128 dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->fmt->type, TRUE); | |
129 | |
130 fprintf(fh, | |
131 "%sType : %s\n" | |
132 "%sInternal blocks : %d\n", | |
133 indent, typeStr, | |
134 indent, img->nblocks); | |
135 | |
136 if (img->fmt->type & D64_FMT_ILACE) | |
137 { | |
138 char *tmps; | |
139 switch (img->laceType) | |
140 { | |
141 case D64_ILACE_COLOR: tmps = "color"; break; | |
142 case D64_ILACE_RES: tmps = "resolution"; break; | |
143 default: tmps = "ERROR"; break; | |
144 } | |
145 fprintf(fh, | |
146 "%sInterlace type : %s\n", | |
147 indent, tmps); | |
148 } | |
149 | |
150 fprintf(fh, | |
151 "%sWidth x Height : %d x %d\n" | |
152 "%sCHwidth x CHheight : %d x %d\n" | |
153 "%sd020 / border : %d ($%02x)\n" | |
154 "%sd021 / background : %d ($%02x)\n", | |
155 indent, img->fmt->width, img->fmt->height, | |
156 indent, img->fmt->chWidth, img->fmt->chHeight, | |
157 indent, img->d020, img->d020, | |
158 indent, img->bgcolor, img->bgcolor); | |
159 } | |
160 else | |
161 if (fmt != NULL) | |
162 { | |
163 dmC64GetImageTypeString(typeStr, sizeof(typeStr), fmt->format->type, TRUE); | |
164 fprintf(fh, | |
165 "%sType : %s\n" | |
166 "%sWidth x Height : %d x %d\n" | |
167 "%sCHwidth x CHheight : %d x %d\n", | |
168 indent, typeStr, | |
169 indent, fmt->format->width, fmt->format->height, | |
170 indent, fmt->format->chWidth, fmt->format->chHeight); | |
171 } | |
172 } | |
173 | 89 |
174 | 90 |
175 int dmC64SetImagePalette(DMImage *img, const DMC64Palette *ppal, const BOOL mixed) | 91 int dmC64SetImagePalette(DMImage *img, const DMC64Palette *ppal, const BOOL mixed) |
176 { | 92 { |
177 const DMC64Palette *cpal = ppal; | 93 const DMC64Palette *cpal = ppal; |