]> git.draconx.ca Git - liblbx.git/blobdiff - src/image.c
Initial implementation of the lbximg tool.
[liblbx.git] / src / image.c
index 336cd98ebd4951cfb049d24c10db6f3eeaf55864..ba642d026b740d09b389b3eea195965da90acf3e 100644 (file)
@@ -29,7 +29,7 @@ struct lbx_image {
 
 struct lbx_image *lbximg_fopen(FILE *f)
 {
-       struct lbx_image tmp = {.f = f}, *new;
+       struct lbx_image tmp = {.f = f}, *new = NULL;
 
        if (fread(&tmp.width,  sizeof tmp.width,   1, f) != 1) goto readerr;
        if (fread(&tmp.height, sizeof tmp.height,  1, f) != 1) goto readerr;
@@ -51,8 +51,8 @@ struct lbx_image *lbximg_fopen(FILE *f)
         * If we never find any exceptions, we can replace the assertions with
         * assumptions.
         */
-       assert(tmp.wtf1 == 0);
-       assert(tmp.offs == tmp.frames + 1);
+       _lbx_assert(tmp.wtf1 == 0);
+       _lbx_assert(tmp.offs == tmp.frames + 1);
 
        new = malloc(sizeof *new + tmp.offs * sizeof *new->offsets);
        if (!new) {
@@ -292,6 +292,15 @@ readerr:
        return -1;
 }
 
+void lbximg_getinfo(struct lbx_image *img, struct lbx_imginfo *info)
+{
+       *info = (struct lbx_imginfo) {
+               .width   = img->width,
+               .height  = img->height,
+               .nframes = img->frames,
+       };
+}
+
 void lbximg_close(struct lbx_image *img)
 {
        if (!img) return;