Mercurial > hg > dmlib
changeset 1720:77a4d8fab5cc
Add output buffer cropping to dmFinishRLEBuffers() and the flags and fields to DMGrowBuf.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 06 Jun 2018 15:19:40 +0300 |
parents | 8f47bd264458 |
children | c9a6f1dae756 |
files | tools/lib64gfx.c tools/lib64gfx.h |
diffstat | 2 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/lib64gfx.c Wed Jun 06 15:18:25 2018 +0300 +++ b/tools/lib64gfx.c Wed Jun 06 15:19:40 2018 +0300 @@ -350,6 +350,22 @@ memmove(dst->data, dst->data + dst->offs, dst->len); dst->offs = 0; } + + switch (cfg->flags & DM_OUT_CROP_MASK) + { + case DM_OUT_CROP_END: + if (cfg->cropOutLen < dst->len) + { + memmove(dst->data, dst->data + dst->len - cfg->cropOutLen + 1, cfg->cropOutLen); + dst->len = cfg->cropOutLen; + } + break; + + case DM_OUT_CROP_START: + if (cfg->cropOutLen <= dst->len) + dst->len = cfg->cropOutLen; + break; + } }
--- a/tools/lib64gfx.h Wed Jun 06 15:18:25 2018 +0300 +++ b/tools/lib64gfx.h Wed Jun 06 15:19:40 2018 +0300 @@ -232,6 +232,11 @@ DM_RLE_BACKWARDS_INPUT = 0x0100, DM_RLE_BACKWARDS_OUTPUT = 0x0200, + + DM_OUT_CROP_NONE = 0x0000, + DM_OUT_CROP_START = 0x1000, + DM_OUT_CROP_END = 0x2000, + DM_OUT_CROP_MASK = 0xf000, }; @@ -240,6 +245,8 @@ char *func; int type; int flags; + size_t cropOutLen; + Uint8 // DM_COMP_RLE_MARKER mode rleMarkerB, // Marker byte for byte length runs (if DM_RLE_BYTE_RUNS used)