# HG changeset patch # User Matti Hamalainen # Date 1543855905 -7200 # Node ID 0a1fe72be4a937e0f957a29ba740a8b40e5f5048 # Parent 3829c292df02853e1cf1bac09eb6a2b26be6990e# Parent 186cf6a7d63487cee08d80835fb6ab7942c59926 Merge. diff -r 186cf6a7d634 -r 0a1fe72be4a9 tools/libgfx.c --- a/tools/libgfx.c Mon Dec 03 10:53:32 2018 +0200 +++ b/tools/libgfx.c Mon Dec 03 18:51:45 2018 +0200 @@ -396,6 +396,42 @@ } +static int dmWriteCDumpRow(void *cbdata, const Uint8 *row, const size_t len) +{ + DMResource *fp = (DMResource *) cbdata; + for (size_t n = 0; n < len; n++) + { + dmfprintf(fp, "0x%02x, ", row[n]); + } + + dmfprintf(fp, "\n"); + + return DMERR_OK; +} + + +int dmWriteCDumpImage(DMResource *fp, const DMImage *img, const DMImageConvSpec *spec) +{ + int res; + + dmfprintf(fp, + "#define SET_WIDTH %d\n" + "#define SET_HEIGHT %d\n" + "\n" + "Uint8 img_data[] = {\n", + + img->width * spec->scaleX, + img->height * spec->scaleY); + + res = dmWriteImageData(img, (void *) fp, dmWriteCDumpRow, spec); + + dmfprintf(fp, + "};\n"); + + return res; +} + + static int dmWritePPMRow(void *cbdata, const Uint8 *row, const size_t len) { if (dmf_write_str((DMResource *) cbdata, row, len)) @@ -2311,6 +2347,11 @@ "araw", "IFFMaster Amiga RAW", DM_IMGFMT_ARAW, DM_FMT_WR, NULL, NULL, dmWriteRAWImage, + }, + { + "cdump", "'C' dump (8-bit indexed image data only)", + DM_IMGFMT_CDUMP, DM_FMT_WR, + NULL, NULL, dmWriteCDumpImage, } }; diff -r 186cf6a7d634 -r 0a1fe72be4a9 tools/libgfx.h --- a/tools/libgfx.h Mon Dec 03 10:53:32 2018 +0200 +++ b/tools/libgfx.h Mon Dec 03 18:51:45 2018 +0200 @@ -25,6 +25,7 @@ DM_IMGFMT_IFF, DM_IMGFMT_RAW, DM_IMGFMT_ARAW, + DM_IMGFMT_CDUMP, };