Mercurial > hg > dmlib
changeset 1912:8d006508e6c1
Implement write support for ECI Graphic Editor 1.0 packed format.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 27 Jun 2018 13:13:57 +0300 |
parents | 794cbb938a58 |
children | cdf95a4d5282 |
files | tools/lib64fmts.c |
diffstat | 1 files changed, 37 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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] },