Mercurial > hg > dmlib
changeset 1488:c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 11 May 2018 05:23:07 +0300 |
parents | 06df2bdf5dc4 |
children | 71e847ea9d22 |
files | tools/64vw.c tools/lib64gfx.c tools/lib64gfx.h |
diffstat | 3 files changed, 50 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/64vw.c Fri May 11 04:55:28 2018 +0300 +++ b/tools/64vw.c Fri May 11 05:23:07 2018 +0300 @@ -164,44 +164,6 @@ } -void dmDumpC64Image(const char *filename, const DMC64Image *img, const DMC64ImageFormat *fmt) -{ - char typeStr[64]; - - dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->type); - - dmPrint(1, - "\n%s\n" - "Format : %s [%s]\n" - "Type : %s\n" - "Banks : %d\n", - filename, - fmt->name, fmt->fext, - typeStr, - img->nbanks); - - if (img->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; - } - dmPrint(1, - "Interlace type : %s\n", - tmps); - } - - dmPrint(1, - "Width x Height : %d x %d\n" - "CHwidth x CHheight : %d x %d\n", - img->width, img->height, - img->chWidth, img->chHeight); -} - - int dmReadC64Image(const char *filename, const DMC64ImageFormat *forced, const DMC64ImageFormat **fmt, DMC64Image **cimage) { Uint8 *dataBuf = NULL; @@ -300,7 +262,8 @@ } else { - dmDumpC64Image(filename, cimage, fmt); + fprintf(stdout, "\n%s\n", filename); + dmC64ImageDump(stdout, cimage, fmt); } dmC64ImageFree(cimage); @@ -417,7 +380,11 @@ cimage->width, cimage->height, currIndex + 1, noptFilenames2); - dmDumpC64Image(filename, cimage, fmt); + if (dmVerbosity >= 1) + { + fprintf(stdout, "\n%s\n", filename); + dmC64ImageDump(stdout, cimage, fmt); + } } fail:
--- a/tools/lib64gfx.c Fri May 11 04:55:28 2018 +0300 +++ b/tools/lib64gfx.c Fri May 11 05:23:07 2018 +0300 @@ -41,6 +41,47 @@ #define DM_GET_ADDR_HI(addr) (((addr) >> 8) & 0xff) +void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt) +{ + char typeStr[64]; + + dmC64GetImageTypeString(typeStr, sizeof(typeStr), img->type); + + if (fmt != NULL) + { + fprintf(fh, + "Format : %s [%s]\n", + fmt->name, fmt->fext); + } + + fprintf(fh, + "Type : %s\n" + "Banks : %d\n", + typeStr, + img->nbanks); + + if (img->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, + "Interlace type : %s\n", + tmps); + } + + fprintf(fh, + "Width x Height : %d x %d\n" + "CHwidth x CHheight : %d x %d\n", + img->width, img->height, + img->chWidth, img->chHeight); +} + + void dmSetDefaultC64Palette(DMImage *img) { img->constpal = TRUE;
--- a/tools/lib64gfx.h Fri May 11 04:55:28 2018 +0300 +++ b/tools/lib64gfx.h Fri May 11 05:23:07 2018 +0300 @@ -194,6 +194,8 @@ extern const DMC64ImageFormat dmC64ImageFormats[]; extern const int ndmC64ImageFormats; + +void dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt); void dmSetDefaultC64Palette(DMImage *img);