[gthumb] raw files: get the original imae size correctly
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] raw files: get the original imae size correctly
- Date: Sat, 9 Nov 2013 19:59:57 +0000 (UTC)
commit e10600c12009baa5ba390a0b0248188afe1878f2
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Oct 6 14:20:25 2013 +0200
raw files: get the original imae size correctly
extensions/raw_files/gth-metadata-provider-raw.c | 2 +-
extensions/raw_files/main.c | 49 +++++++++++++++++----
2 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/extensions/raw_files/gth-metadata-provider-raw.c
b/extensions/raw_files/gth-metadata-provider-raw.c
index 32f058e..c05b58c 100644
--- a/extensions/raw_files/gth-metadata-provider-raw.c
+++ b/extensions/raw_files/gth-metadata-provider-raw.c
@@ -69,7 +69,7 @@ gth_metadata_provider_raw_read (GthMetadataProvider *self,
libraw_data_t *raw_data;
GInputStream *istream = NULL;
int result;
- void *buffer;
+ void *buffer = NULL;
size_t buffer_size;
char *size;
guint width, height;
diff --git a/extensions/raw_files/main.c b/extensions/raw_files/main.c
index 652b28f..abb804c 100644
--- a/extensions/raw_files/main.c
+++ b/extensions/raw_files/main.c
@@ -313,6 +313,35 @@ _cairo_image_surface_create_from_raw (GInputStream *istream,
cairo_surface_destroy (rotated);
cairo_surface_destroy (surface);
}
+
+ /* get the original size */
+
+ if ((original_width != NULL) && (original_height != NULL)) {
+ libraw_close (raw_data);
+
+ raw_data = libraw_init (LIBRAW_OPIONS_NO_MEMERR_CALLBACK |
LIBRAW_OPIONS_NO_DATAERR_CALLBACK);
+ if (raw_data == NULL)
+ goto fatal_error;
+
+ result = libraw_open_buffer (raw_data, buffer, size);
+ if (LIBRAW_FATAL_ERROR (result))
+ goto fatal_error;
+
+ result = libraw_unpack (raw_data);
+ if (result != LIBRAW_SUCCESS) {
+ _libraw_set_gerror (error, result);
+ goto fatal_error;
+ }
+
+ 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;
+ }
}
else
@@ -363,19 +392,19 @@ _cairo_image_surface_create_from_raw (GInputStream *istream,
}
libraw_dcraw_clear_mem (processed_image);
- }
- /* get the original size */
+ /* 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;
- }
+ 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;
+ *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]