diff tools/64vw.c @ 1730:881a3fc421d8

Use the default C64 palette whenever we need it, but make it possible to override it.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 08 Jun 2018 22:03:19 +0300
parents f4015f6cb173
children 5e928618fdc8
line wrap: on
line diff
--- a/tools/64vw.c	Thu Jun 07 15:54:19 2018 +0300
+++ b/tools/64vw.c	Fri Jun 08 22:03:19 2018 +0300
@@ -210,17 +210,23 @@
     DMImage bmap;
     int ret;
 
-    bmap.size = surf->pitch * surf->h;
-    bmap.data = surf->pixels;
-    bmap.pitch = surf->pitch;
-    bmap.width = surf->w;
-    bmap.height = surf->h;
+    memset(&bmap, 0, sizeof(bmap));
+    bmap.size     = surf->pitch * surf->h;
+    bmap.data     = surf->pixels;
+    bmap.pitch    = surf->pitch;
+    bmap.width    = surf->w;
+    bmap.height   = surf->h;
+    bmap.ncolors  = C64_NCOLORS;
+    bmap.constpal = TRUE;
+    bmap.pal      = dmDefaultC64Palette;
 
     if (fmt->convertFrom != NULL)
         ret = fmt->convertFrom(&bmap, cimage, fmt);
     else
         ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt);
 
+    SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal, 0, bmap.ncolors);
+
     return ret;
 }
 
@@ -485,7 +491,6 @@
                 goto exit;
             }
 
-            SDL_SetPaletteColors(surf->format->palette, (SDL_Color *)dmDefaultC64Palette, 0, C64_NCOLORS);
 
             if (texture != NULL)
                 SDL_DestroyTexture(texture);