Mercurial > hg > dmlib
diff tools/lib64gfx.c @ 1713:0a9110b4d036
Add few RLE helper functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 06 Jun 2018 14:31:04 +0300 |
parents | 1f0fac3af8e3 |
children | c0c6fd8b288a |
line wrap: on
line diff
--- a/tools/lib64gfx.c Wed Jun 06 14:29:05 2018 +0300 +++ b/tools/lib64gfx.c Wed Jun 06 14:31:04 2018 +0300 @@ -327,7 +327,7 @@ } -static void dmSetupRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg) +void dmSetupRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg) { if (cfg->flags & DM_RLE_BACKWARDS_INPUT) { @@ -340,6 +340,30 @@ dst->backwards = TRUE; dst->offs = dst->size - 1; } +void dmFinishRLEBuffers(DMGrowBuf *dst, DMGrowBuf *src, const DMCompParams *cfg) +{ + if (cfg->flags & DM_RLE_BACKWARDS_OUTPUT) + { + memmove(dst->data, dst->data + dst->offs, dst->len); + dst->offs = 0; + } +} + + +int dmGenericRLEOutputRun(DMGrowBuf *dst, const DMCompParams *cfg, const Uint8 data, const unsigned int count) +{ + unsigned int scount; + for (scount = count; scount; scount--) + { + if (!dmGrowBufPutU8(dst, data)) + { + return dmError(DMERR_MALLOC, + "%s: RLE: Could not output RLE run %d x 0x%02x @ " + "offs=0x%" DM_PRIx_SIZE_T ", size=0x%" DM_PRIx_SIZE_T ".\n", + cfg->func, count, data, dst->offs, dst->size); + } + } + return DMERR_OK; }