]> git.draconx.ca Git - liblbx.git/blobdiff - src/image.c
lbxgui: Add support for animating images.
[liblbx.git] / src / image.c
index f98238e49edb0f79395551d14ed4c7c9e66599fb..c8a71650fbb872f24a7a7140e8e96a43e4eaedc0 100644 (file)
@@ -282,15 +282,16 @@ unsigned char **lbximg_getframe(struct lbx_image *img, int frame)
                        return NULL;
        }
 
-       /* Start over if we are backtracking. */
-       if (img->currentframe > frame)
-               img->currentframe == -1;
-
        if (img->flags & FLAG_OVERWRITE) {
                /* Clear the slate. */
+               img->currentframe = -1;
                memset(img->framedata[0], 0, img->width * img->height);
                memset(img->mask[0],      0, img->width * img->height);
        } else {
+               /* Start over if we are backtracking. */
+               if (img->currentframe > frame)
+                       img->currentframe = -1;
+
                /* We must have previous frame decoded to continue. */
                if (frame > img->currentframe + 1) {
                        if (!lbximg_getframe(img, frame-1))
@@ -340,9 +341,10 @@ int lbximg_loadpalette(FILE *f, struct lbx_colour palette[static 256])
                }
 
                palette[i] = (struct lbx_colour){
-                       .red   = entry[1] << 2,
-                       .green = entry[2] << 2,
-                       .blue  = entry[3] << 2,
+                       .red    = entry[1] << 2,
+                       .green  = entry[2] << 2,
+                       .blue   = entry[3] << 2,
+                       .active = 1,
                };
        }
 
@@ -367,7 +369,6 @@ lbximg_getpalette(struct lbx_image *img, struct lbx_colour palette[static 256])
 
        for (i = 0; i < img->palcount; i++) {
                rc = img->fops->read(entry, sizeof entry, img->f);
-
                if (rc < sizeof entry) {
                        goto readerr;
                }
@@ -378,9 +379,10 @@ lbximg_getpalette(struct lbx_image *img, struct lbx_colour palette[static 256])
                }
 
                palette[img->palstart + i] = (struct lbx_colour){
-                       .red   = entry[1] << 2,
-                       .green = entry[2] << 2,
-                       .blue  = entry[3] << 2,
+                       .red    = entry[1] << 2,
+                       .green  = entry[2] << 2,
+                       .blue   = entry[3] << 2,
+                       .active = 1,
                };
        }