diff tools/64vw.c @ 2094:4276b8c0fef0

Revamp how the DMImage palette system and color formats work, as preparation for future work on supporting non-indexed/paletted images. It is still messy.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Mar 2019 09:56:47 +0200
parents dcca36701cdd
children e0281dae2cb8
line wrap: on
line diff
--- a/tools/64vw.c	Thu Feb 28 12:32:07 2019 +0200
+++ b/tools/64vw.c	Tue Mar 05 09:56:47 2019 +0200
@@ -220,16 +220,18 @@
     bmap.pitch    = surf->pitch;
     bmap.width    = surf->w;
     bmap.height   = surf->h;
-    bmap.ncolors  = C64_NCOLORS;
-    bmap.constpal = TRUE;
-    bmap.pal      = dmDefaultC64Palette;
+
+    if ((ret = dmSetDefaultC64Palette(&bmap)) != DMERR_OK)
+        return ret;
 
     if (fmt->format->convertFrom != NULL)
         ret = fmt->format->convertFrom(&bmap, cimage, fmt, spec);
     else
         ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt, spec);
 
-    SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal, 0, bmap.ncolors);
+    SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal->colors, 0, bmap.pal->ncolors);
+
+    dmPaletteFree(bmap.pal);
 
     return ret;
 }