Mercurial > hg > dmlib
diff 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 |
line wrap: on
line diff
--- a/tools/lib64gfx.c Fri Jun 14 01:58:05 2019 +0300 +++ b/tools/lib64gfx.c Fri Jun 14 03:24:24 2019 +0300 @@ -88,90 +88,6 @@ const int ndmC64DefaultPalettes = sizeof(dmC64DefaultPalettes) / sizeof(dmC64DefaultPalettes[0]); -char * dmC64GetImageTypeString(char *buf, const size_t len, const int type, const BOOL lng) -{ - static const char *fmtModesShort[] = { "*", "HiR", "MC", "ECM" }; - static const char *fmtModesLong[] = { "*", "HiRes", "MultiColor", "Extended Color Mode" }; - const char *fmtStr; - size_t nfmt = type & D64_FMT_MODE_MASK; - - if (nfmt < sizeof(fmtModesShort) / sizeof(fmtModesShort[0])) - fmtStr = lng ? fmtModesLong[nfmt] : fmtModesShort[nfmt]; - else - fmtStr = lng ? "ERROR" : "ERR"; - - snprintf(buf, len, - "%s %s%s%s", - fmtStr, - (type & D64_FMT_ILACE) ? (lng ? "Interlaced " : "ILace ") : "", - (type & D64_FMT_FLI) ? "FLI " : "", - (type & D64_FMT_CHAR) ? "CHAR" : "" - ); - - return buf; -} - - -void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt, const char *indent) -{ - char typeStr[64]; - - if (fmt != NULL) - { - fprintf(fh, - "%sFormat : %s [%s]\n", - indent, fmt->name, fmt->fext); - } - - if (img != NULL) - { - dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->fmt->type, TRUE); - - fprintf(fh, - "%sType : %s\n" - "%sInternal blocks : %d\n", - indent, typeStr, - indent, img->nblocks); - - if (img->fmt->type & D64_FMT_ILACE) - { - char *tmps; - switch (img->laceType) - { - case D64_ILACE_COLOR: tmps = "color"; break; - case D64_ILACE_RES: tmps = "resolution"; break; - default: tmps = "ERROR"; break; - } - fprintf(fh, - "%sInterlace type : %s\n", - indent, tmps); - } - - fprintf(fh, - "%sWidth x Height : %d x %d\n" - "%sCHwidth x CHheight : %d x %d\n" - "%sd020 / border : %d ($%02x)\n" - "%sd021 / background : %d ($%02x)\n", - indent, img->fmt->width, img->fmt->height, - indent, img->fmt->chWidth, img->fmt->chHeight, - indent, img->d020, img->d020, - indent, img->bgcolor, img->bgcolor); - } - else - if (fmt != NULL) - { - dmC64GetImageTypeString(typeStr, sizeof(typeStr), fmt->format->type, TRUE); - fprintf(fh, - "%sType : %s\n" - "%sWidth x Height : %d x %d\n" - "%sCHwidth x CHheight : %d x %d\n", - indent, typeStr, - indent, fmt->format->width, fmt->format->height, - indent, fmt->format->chWidth, fmt->format->chHeight); - } -} - - int dmC64SetImagePalette(DMImage *img, const DMC64Palette *ppal, const BOOL mixed) { const DMC64Palette *cpal = ppal;