src/lib/image.c
changeset 7 997906f5fd2d
parent 6 766df7c9b90d
child 8 400ddf1e7aa9
--- a/src/lib/image.c	Mon Dec 28 22:31:33 2009 +0200
+++ b/src/lib/image.c	Mon Dec 28 22:50:00 2009 +0200
@@ -95,6 +95,20 @@
 }
 
 /**
+ * Update the image_info field from the given png object.
+ *
+ * Must be called under libpng-error-trap!
+ */
+static int pt_image_update_info (struct pt_image *image, png_structp png, png_infop info)
+{
+    // query png_get_*
+    image->info.width = png_get_image_width(png, info); 
+    image->info.height = png_get_image_height(png, info); 
+
+    return 0;
+}
+
+/**
  * Open the PNG image, and write out to the cache
  */
 static int pt_image_update_cache (struct pt_image *image)
@@ -119,6 +133,10 @@
     // read meta-info
     png_read_info(png, info);
 
+    // update our meta-info
+    if (pt_image_update_info(image, png, info))
+        goto error;
+
     // pass to cache object
     if (pt_cache_update_png(image->cache, png, info))
         goto error;
@@ -177,6 +195,14 @@
     return -1;
 }
 
+int pt_image_info (struct pt_image *image, const struct pt_image_info **info_ptr)
+{
+    // XXX: ensure that this was read?
+    *info_ptr = &image->info;
+
+    return 0;
+}
+
 int pt_image_stale (struct pt_image *image)
 {
     return pt_cache_stale(image->cache, image->path);