changeset 1538:af729e29a6f6

Implement Amica Paint packed format encoding.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 12 May 2018 04:54:36 +0300
parents 776aa43b2c57
children 2acf4578d2e6
files tools/lib64fmts.c
diffstat 1 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64fmts.c	Sat May 12 04:46:08 2018 +0300
+++ b/tools/lib64fmts.c	Sat May 12 04:54:36 2018 +0300
@@ -202,6 +202,29 @@
 }
 
 
+static int fmtEncodeAmicaPaintPacked(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;
+
+    // And now RLE compress the data to the existing buffer
+    cfg.type = DM_COMP_RLE_MARKER;
+    cfg.rleMarker = 0xC2;
+    cfg.rleMinCount = 3;
+    cfg.rleMaxCount = 255;
+    res = dmEncodeGenericRLE(buf, tmp.data, tmp.data + tmp.len, &cfg);
+
+out:
+    dmGrowBufFree(&tmp);
+    return res;
+}
+
+
 static int fmtProbeFLIDesigner(const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt)
 {
     if (len == fmt->size &&
@@ -622,7 +645,7 @@
         C64_SCR_WIDTH / 2, C64_SCR_HEIGHT,
         C64_SCR_CH_WIDTH , C64_SCR_CH_HEIGHT,
         fmtProbeAmicaPaintPacked,
-        fmtDecodeAmicaPaintPacked, fmtEncodeStub,
+        fmtDecodeAmicaPaintPacked, fmtEncodeAmicaPaintPacked,
         NULL, NULL,
         NULL,
         {