changeset 1872:fe15412eec10

Actually fix also the ARAW/RAW image data writing to honor the scaling.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 24 Jun 2018 19:07:43 +0300
parents 7d615a735ce1
children 91705a2bc3a4
files tools/libgfx.c
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/tools/libgfx.c	Sun Jun 24 18:58:58 2018 +0300
+++ b/tools/libgfx.c	Sun Jun 24 19:07:43 2018 +0300
@@ -300,6 +300,19 @@
 }
 
 
+static BOOL dmWriteRAWRow(DMBitStreamContext *bs, const DMImage *img, const DMImageConvSpec *spec, const int yc, const int plane)
+{
+    const Uint8 *sp = img->data + (yc * img->pitch);
+    for (int xc = 0; xc < img->width; xc++)
+    {
+        for (int xscale = 0; xscale < spec->scaleX; xscale++)
+        if (!dmPutBits(bs, (sp[xc] & (1 << plane)) ? 1 : 0, 1))
+            return FALSE;
+    }
+    return TRUE;
+}
+
+
 int dmWriteRAWImageFILE(DMResource *fp, const DMImage *img, const DMImageConvSpec *spec)
 {
     int res;
@@ -313,14 +326,11 @@
         // Output bitplanes in planar format
         // (each plane of line sequentially)
         for (int yc = 0; yc < img->height; yc++)
+        for (int yscale = 0; yscale < spec->scaleY; yscale++)
         for (int plane = 0; plane < spec->nplanes; plane++)
         {
-            Uint8 *sp = img->data + yc * img->pitch;
-            for (int xc = 0; xc < img->width; xc++)
-            {
-                if (!dmPutBits(&bs, (sp[xc] & (1 << plane)) ? 1 : 0, 1))
-                    return DMERR_FWRITE;
-            }
+            if (!dmWriteRAWRow(&bs, img, spec, yc, plane))
+                return DMERR_FWRITE;
         }
     }
     else
@@ -328,13 +338,10 @@
         // Output each bitplane in sequence
         for (int plane = 0; plane < spec->nplanes; plane++)
         for (int yc = 0; yc < img->height; yc++)
+        for (int yscale = 0; yscale < spec->scaleY; yscale++)
         {
-            Uint8 *sp = img->data + yc * img->pitch;
-            for (int xc = 0; xc < img->width; xc++)
-            {
-                if (!dmPutBits(&bs, (sp[xc] & (1 << plane)) ? 1 : 0, 1))
-                    return DMERR_FWRITE;
-            }
+            if (!dmWriteRAWRow(&bs, img, spec, yc, plane))
+                return DMERR_FWRITE;
         }
     }