diff tools/view64.c @ 931:2270d7f3af77

Refactor the DMC64Image handling to be more dynamic, and start work on allowing non 320/160 x 200 formats, and charmode based formats. There is still work to be done, and some problems to sort out.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Feb 2015 19:37:59 +0200
parents daebbf28953d
children 8fe48c08dbca
line wrap: on
line diff
--- a/tools/view64.c	Wed Feb 25 19:32:55 2015 +0200
+++ b/tools/view64.c	Wed Feb 25 19:37:59 2015 +0200
@@ -157,7 +157,7 @@
     DMImage bmap;
     BOOL initSDL = FALSE, exitFlag, needRedraw;
     const DMC64ImageFormat *fmt = NULL, *forced;
-    DMC64Image image;
+    DMC64Image *cimage = NULL;
     char *windowTitle;
     Uint8 *dataBuf = NULL;
     size_t dataSize;
@@ -194,7 +194,7 @@
     else
         forced = NULL;
 
-    ret = dmC64DecodeBMP(&image, dataBuf, dataSize, 0, 2, &fmt, forced);
+    ret = dmC64DecodeBMP(&cimage, dataBuf, dataSize, 0, 2, &fmt, forced);
     if (forced == NULL && fmt != NULL)
     {
         dmMsg(0,"Probed %s format image, type %d, %s\n",
@@ -231,6 +231,7 @@
     SDL_SetColors(screen, (SDL_Color *)dmC64Palette, 0, C64_NCOLORS);
 
     // Convert bitmap (this is a bit ugly and lazy here)
+    bmap.size = surf->pitch * surf->h;
     bmap.data = surf->pixels;
     bmap.pitch = surf->pitch;
     bmap.width = surf->w;
@@ -238,9 +239,9 @@
     bmap.constpal = TRUE;
 
     if (fmt->convertFrom != NULL)
-        ret = fmt->convertFrom(&bmap, &image, TRUE);
+        ret = fmt->convertFrom(&bmap, cimage, TRUE);
     else
-        ret = dmC64ConvertGenericBMP2Image(&bmap, &image, TRUE);
+        ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, TRUE);
 
 
     // Set window title and caption