[gthumb] raw: use libraw_adjust_sizes_info_only to get the real image size



commit 212dccab749dc83e82781092b6bcac8de07082c3
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Jun 24 18:11:41 2013 +0200

    raw: use libraw_adjust_sizes_info_only to get the real image size

 extensions/raw_files/gth-metadata-provider-raw.c |   21 ++++++----------
 extensions/raw_files/main.c                      |   27 +++++++++-------------
 2 files changed, 19 insertions(+), 29 deletions(-)
---
diff --git a/extensions/raw_files/gth-metadata-provider-raw.c 
b/extensions/raw_files/gth-metadata-provider-raw.c
index 675f0f9..32f058e 100644
--- a/extensions/raw_files/gth-metadata-provider-raw.c
+++ b/extensions/raw_files/gth-metadata-provider-raw.c
@@ -92,22 +92,17 @@ gth_metadata_provider_raw_read (GthMetadataProvider *self,
        if (LIBRAW_FATAL_ERROR (result))
                goto fatal_error;
 
+       result = libraw_unpack (raw_data);
+       if (result != LIBRAW_SUCCESS)
+               goto fatal_error;
+
+       result = libraw_adjust_sizes_info_only (raw_data);
+       if (result != LIBRAW_SUCCESS)
+               goto fatal_error;
+
        width = raw_data->sizes.iwidth;
        height = raw_data->sizes.iheight;
 
-       switch (raw_data->sizes.flip) {
-       case 5: /* 270 degrees */
-       case 6: /* 90 degrees */
-       {
-               int tmp = width;
-               width = height;
-               height = tmp;
-               break;
-       }
-       default:
-               break;
-       }
-
        g_file_info_set_attribute_string (file_data->info, "general::format", _("RAW Format"));
        g_file_info_set_attribute_int32 (file_data->info, "image::width", width);
        g_file_info_set_attribute_int32 (file_data->info, "image::height", height);
diff --git a/extensions/raw_files/main.c b/extensions/raw_files/main.c
index e26e7dc..d0775c9 100644
--- a/extensions/raw_files/main.c
+++ b/extensions/raw_files/main.c
@@ -200,7 +200,6 @@ _cairo_image_surface_create_from_raw (GInputStream  *istream,
        int            result;
        void          *buffer = NULL;
        size_t         size;
-       int            width, height;
        GthImage      *image = NULL;
 
        raw_data = libraw_init (LIBRAW_OPIONS_NO_MEMERR_CALLBACK | LIBRAW_OPIONS_NO_DATAERR_CALLBACK);
@@ -222,24 +221,9 @@ _cairo_image_surface_create_from_raw (GInputStream  *istream,
                goto fatal_error;
        }
 
-       /* get the original size */
 
-       width = raw_data->sizes.iwidth;
-       height = raw_data->sizes.iheight;
 
-       switch (raw_data->sizes.flip) {
-       case 5: /* 270 degrees */
-       case 6: /* 90 degrees */
-               swap_int (&width, &height);
-               break;
-       default:
-               break;
-       }
 
-       if (original_width)
-               *original_width = width;
-       if (original_height)
-               *original_height = height;
 
        /* read the thumbnail */
 
@@ -275,6 +259,17 @@ _cairo_image_surface_create_from_raw (GInputStream  *istream,
 
        if ((image != NULL) && (raw_data->sizes.pixel_aspect != 1.0)) {
                /* FIXME: scale */
+       /* get the original size */
+
+       if ((original_width != NULL) && (original_height != NULL)) {
+               result = libraw_adjust_sizes_info_only (raw_data);
+               if (result != LIBRAW_SUCCESS) {
+                       _libraw_set_gerror (error, result);
+                       goto fatal_error;
+               }
+
+               *original_width = raw_data->sizes.iwidth;
+               *original_height = raw_data->sizes.iheight;
        }
 
        fatal_error:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]