# HG changeset patch # User Matti Hamalainen # Date 1530094437 -10800 # Node ID 8d006508e6c1caff743e100679b9c69363507422 # Parent 794cbb938a588dd3cc59cb800e923dec719cbff9 Implement write support for ECI Graphic Editor 1.0 packed format. diff -r 794cbb938a58 -r 8d006508e6c1 tools/lib64fmts.c --- a/tools/lib64fmts.c Tue Jun 26 20:20:00 2018 +0300 +++ b/tools/lib64fmts.c Wed Jun 27 13:13:57 2018 +0300 @@ -972,6 +972,41 @@ } +static int fmtEncodeECIPacked(DMGrowBuf *buf, const DMC64Image *img, const DMC64ImageFormat *fmt) +{ + int res; + DMGrowBuf tmp; + DMCompParams cfg; + + // Encode the data to temp buffer + if ((res = dmC64EncodeGenericBMP(TRUE, &tmp, img, fmt)) != DMERR_OK) + goto out; + + // Analyze and setup RLE + cfg.func = fmt->name; + cfg.type = DM_COMP_RLE_MARKER; + cfg.flags = DM_RLE_BYTE_RUNS | DM_RLE_ORDER_1; + cfg.rleMinCountB = 4; + cfg.rleMaxCountB = 255; + + dmGenericRLEAnalyze(&tmp, &cfg); + + // Add the header bits + if (!dmGrowBufPutU8(buf, cfg.rleMarkerB)) + { + res = DMERR_MALLOC; + goto out; + } + + // And now RLE compress the data to the existing buffer + res = dmEncodeGenericRLE(buf, &tmp, &cfg); + +out: + dmGrowBufFree(&tmp); + return res; +} + + // // Helper macros for defining screen memory layouts // common for several FLI type image formats @@ -1620,9 +1655,9 @@ }, { - "ecp", "ECI Graphic Editor 1.0 (packed)", 0x4000, 0, DM_FMT_RD, + "ecp", "ECI Graphic Editor 1.0 (packed)", 0x4000, 0, DM_FMT_RDWR, fmtProbeECIPacked, - fmtDecodeECIPacked, NULL, + fmtDecodeECIPacked, fmtEncodeECIPacked, { }, &dmC64CommonFormats[7] },