changeset 1732:07111a60cd4e

Add dmSetMixedColorC64Palette() for setting a 256 entry "mixed color" palette, which consists of averaged 16 x 16 matrix of C64 palette. This can be used for rendering images that use color interlace.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 08 Jun 2018 22:09:00 +0300
parents 474055f25ab0
children 59c2b08a80a6
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Fri Jun 08 22:07:05 2018 +0300
+++ b/tools/lib64gfx.c	Fri Jun 08 22:09:00 2018 +0300
@@ -115,6 +115,29 @@
 }
 
 
+BOOL dmSetMixedColorC64Palette(DMImage *img)
+{
+    if (!dmImagePaletteAlloc(dst, C64_NCOLORS * C64_NCOLORS, -1))
+        return FALSE;
+
+    int n = 0;
+    for (int n1 = 0; n1 < C64_NCOLORS; n1++)
+    {
+        const DMColor *col1 = &dmDefaultC64Palette[n1];
+        for (int n2 = 0; n2 < C64_NCOLORS; n2++)
+        {
+            const DMColor *col2 = &dmDefaultC64Palette[n2];
+            dst->pal[n].r = (col1->r + col2->r) / 2;
+            dst->pal[n].g = (col1->g + col2->g) / 2;
+            dst->pal[n].b = (col1->b + col2->b) / 2;
+            n++;
+        }
+    }
+
+    return TRUE;
+}
+
+
 BOOL dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr)
 {
     return buf[offs    ] == DM_GET_ADDR_LO(addr) &&
--- a/tools/lib64gfx.h	Fri Jun 08 22:07:05 2018 +0300
+++ b/tools/lib64gfx.h	Fri Jun 08 22:09:00 2018 +0300
@@ -284,6 +284,8 @@
 void      dmC64ImageDump(FILE *fh, const DMC64Image *img, const DMC64ImageFormat *fmt);
 
 void      dmSetDefaultC64Palette(DMImage *img);
+BOOL      dmSetMixedColorC64Palette(DMImage *img);
+
 BOOL      dmCompareAddr16(const Uint8 *buf, const size_t offs, const Uint16 addr);
 int       dmC64ImageGetNumBanks(const DMC64ImageFormat *fmt);