]> git.draconx.ca Git - liblbx.git/blobdiff - src/lbximg.c
liblbx: Update lbximg_fopen to work like lbx_fopen.
[liblbx.git] / src / lbximg.c
index 67d8635a8feaf4ba64d75cf1d89d4c026772e243..1173538856b94ae4781a78aedd86795d18719433 100644 (file)
@@ -163,7 +163,6 @@ int outpng(unsigned int frameno,
        }
 
        if (setjmp(png_jmpbuf(png))) {
-               free(row);
                png_destroy_write_struct(&png, &info);
                goto err;
        }
@@ -221,12 +220,11 @@ int outpng(unsigned int frameno,
 
        png_destroy_write_struct(&png, &info);
        fclose(of);
+       free(row);
 
        if (verbose)
                printf("wrote %s\n", name);
-
        return 0;
-
 err:
        fclose(of);
        remove(name);
@@ -236,7 +234,7 @@ err:
 
 static int loadoverride(FILE *f, struct lbx_colour palette[static 256])
 {
-       LBX_IMG *overimg = lbximg_fopen(f);
+       LBX_IMG *overimg = lbximg_open(f, &lbx_default_fops, NULL);
        struct lbx_imginfo info;
 
        if (!overimg) {
@@ -317,7 +315,7 @@ int decode(LBX_IMG *img, FILE *palf, FILE *override, char **argv)
 
        lbximg_getinfo(img, &info);
 
-       framebits = malloc(info.nframes / CHAR_BIT + 1);
+       framebits = calloc(1, info.nframes / CHAR_BIT + 1);
        if (!framebits) {
                return EXIT_FAILURE;
        }
@@ -468,6 +466,7 @@ int main(int argc, char **argv)
                printf("%s is %ux%u LBX image, %u frame(s)%s%s\n",
                       name, info.width, info.height, info.nframes,
                       info.palettesz ? ", embedded palette" : "",
+                      info.chunk     ? ", chunked" : "",
                       info.looping   ? ", loops" : "");
        }