Le Thu, 27 Nov 2008 11:10:54 +0100,
Ille <[EMAIL PROTECTED]> a écrit :
> Hi,
>
> I join some patches to be applied to rawstudio-svn-2079.
>
> The x3f patch permit auto rotation of x3f files according to the x3f
> header's rotation field. It also add a check in dcraw.cc to be sure
> x3f pixels values do not exceed 4095. Surely this check must be done
> somewhere else (to not modify dcraw.cc), but it seemed to me the
> easiest way for now, as my computing skills are not so good.
> It also add two new fields to the metadata struct: exposure and
> sharpness, as those are defined in the x3f header.
> Plus I tried to get the extended data correctly loaded, so that work
> done with Sigma Photo Pro could be reused in rawstudio. the result is
> truly not exact, but I will try to enhance this.
Sorry, the x3f.patch is wrong. I didn't notice before, but x3f files
were opened with the half_size parameter set to FALSE. As far as I have
understand, this sould only be the case for bayer captor. So in
rs_image16_open_xf3() just always send TRUE as half_size parameter when
opening a x3f file. Also, the photo should be opened with dcraw only
after verifying that this is in fact a x3f. And I forgot to close the
rawfile after opening (too bad).
So I join a corrected patch.
diff -urN rawstudio-svn2079.orig/po/fr.po rawstudio-svn2079/po/fr.po
--- rawstudio-svn2079.orig/po/fr.po 2008-11-13 04:15:34.000000000 +0100
+++ rawstudio-svn2079/po/fr.po 2008-11-27 02:44:46.000000000 +0100
@@ -761,7 +761,7 @@
#: src/toolbox.c:504 src/rs-actions.c:353
msgid "Hue"
-msgstr "Teinte"
+msgstr "Hue"
#: src/toolbox.c:505 src/rs-actions.c:354
msgid "Contrast"
diff -urN rawstudio-svn2079.orig/src/dcraw.cc rawstudio-svn2079/src/dcraw.cc
--- rawstudio-svn2079.orig/src/dcraw.cc 2008-10-28 04:15:03.000000000 +0100
+++ rawstudio-svn2079/src/dcraw.cc 2008-11-27 01:25:58.000000000 +0100
@@ -3387,6 +3387,7 @@
FORC3 {
i = image[row*width+col][c] + ipix[c] - sum;
if (i < 0) i = 0;
+ if (i > 4095) i = 4095;
image[row*width+col][c] = i;
}
}
diff -urN rawstudio-svn2079.orig/src/rawstudio.c rawstudio-svn2079/src/rawstudio.c
--- rawstudio-svn2079.orig/src/rawstudio.c 2008-10-28 04:15:03.000000000 +0100
+++ rawstudio-svn2079/src/rawstudio.c 2008-11-27 01:13:01.000000000 +0100
@@ -106,7 +106,7 @@
REGISTER_FILETYPE(".srf", _("Sony"), rs_image16_open_dcraw, rs_tiff_load_meta);
REGISTER_FILETYPE(".kdc", _("Kodak"), rs_image16_open_dcraw, rs_tiff_load_meta);
REGISTER_FILETYPE(".dcr", _("Kodak"), rs_image16_open_dcraw, rs_tiff_load_meta);
- REGISTER_FILETYPE(".x3f", _("Sigma"), rs_image16_open_dcraw, rs_x3f_load_meta);
+ REGISTER_FILETYPE(".x3f", _("Sigma"), rs_image16_open_x3f, rs_x3f_load_meta);
REGISTER_FILETYPE(".orf", _("Olympus"), rs_image16_open_dcraw, rs_tiff_load_meta);
REGISTER_FILETYPE(".raw", _("Panasonic raw"), rs_image16_open_dcraw, rs_tiff_load_meta);
REGISTER_FILETYPE(".pef", _("Pentax raw"), rs_image16_open_dcraw, rs_tiff_load_meta);
diff -urN rawstudio-svn2079.orig/src/rs-metadata.c rawstudio-svn2079/src/rs-metadata.c
--- rawstudio-svn2079.orig/src/rs-metadata.c 2008-10-28 04:15:03.000000000 +0100
+++ rawstudio-svn2079/src/rs-metadata.c 2008-11-27 01:13:01.000000000 +0100
@@ -95,6 +95,8 @@
metadata->cam_mul[0] = -1.0;
metadata->contrast = -1.0;
metadata->saturation = -1.0;
+ metadata->exposure = 0.0;
+ metadata->sharpness = -1.0;
metadata->color_tone = -1.0;
metadata->focallength = -1;
for(i=0;i<4;i++)
diff -urN rawstudio-svn2079.orig/src/rs-metadata.h rawstudio-svn2079/src/rs-metadata.h
--- rawstudio-svn2079.orig/src/rs-metadata.h 2008-10-28 04:15:03.000000000 +0100
+++ rawstudio-svn2079/src/rs-metadata.h 2008-11-27 01:13:01.000000000 +0100
@@ -74,6 +74,8 @@
gdouble contrast;
gdouble saturation;
gdouble color_tone;
+ gdouble exposure;
+ gdouble sharpness;
gshort focallength;
RS_MATRIX4 adobe_coeff;
GdkPixbuf *thumbnail;
diff -urN rawstudio-svn2079.orig/src/rs-photo.c rawstudio-svn2079/src/rs-photo.c
--- rawstudio-svn2079.orig/src/rs-photo.c 2008-10-28 04:15:03.000000000 +0100
+++ rawstudio-svn2079/src/rs-photo.c 2008-11-27 01:13:01.000000000 +0100
@@ -553,9 +553,12 @@
{
/* White balance */
if (!(mask & MASK_WB))
- if (!rs_photo_set_wb_from_camera(photo, i))
- rs_photo_set_wb_auto(photo, i);
-
+ if (!rs_photo_set_wb_from_camera(photo, i)) {
+ if (photo->metadata->make & MAKE_SIGMA)
+ rs_photo_set_wb_from_mul(photo, i, photo->metadata->cam_mul);
+ else
+ rs_photo_set_wb_auto(photo, i);
+ }
/* Contrast */
if (!(mask & MASK_CONTRAST) && (photo->metadata->contrast != -1.0))
rs_photo_set_contrast(photo, i, photo->metadata->contrast);
diff -urN rawstudio-svn2079.orig/src/x3f-meta.c rawstudio-svn2079/src/x3f-meta.c
--- rawstudio-svn2079.orig/src/x3f-meta.c 2008-10-28 04:15:03.000000000 +0100
+++ rawstudio-svn2079/src/x3f-meta.c 2008-11-27 10:13:25.000000000 +0100
@@ -143,25 +144,47 @@
if ((file.version_major == 2) && (file.version_minor == 2))
{
- /* Copy all data types in one go */
- raw_strcpy(rawfile, G_STRUCT_OFFSET(X3F_FILE, extended_data_types), file.extended_data_types, 32);
+
+ meta->cam_mul[0] = .97;
+ meta->cam_mul[1] = 1;
+ meta->cam_mul[2] = 1;
+
+ /* Copy all data types in one go */
+ raw_strcpy(rawfile, G_STRUCT_OFFSET(X3F_FILE, extended_data_types), file.extended_data_types, 32);
for(i=0;i<32;i++)
{
/* This could have endianness problems! */
raw_get_float(rawfile, G_STRUCT_OFFSET(X3F_FILE, extended_data)+i*4, &file.extended_data[i]);
switch (file.extended_data_types[i])
{
case X3F_EXTENDED_DATA_COLOR_ADJUST_RED:
- meta->cam_mul[0] = file.extended_data[i];
+ meta->cam_mul[0] += 1/file.extended_data[i];
break;
case X3F_EXTENDED_DATA_COLOR_ADJUST_GREEN:
- meta->cam_mul[1] = file.extended_data[i];
- meta->cam_mul[3] = file.extended_data[i];
+ meta->cam_mul[1] += 1/file.extended_data[i];
+ meta->cam_mul[3] += 1/file.extended_data[i];
break;
case X3F_EXTENDED_DATA_COLOR_ADJUST_BLUE:
- meta->cam_mul[2] = file.extended_data[i];
+ meta->cam_mul[2] += 1/file.extended_data[i];
+ break;
+ case X3F_EXTENDED_DATA_SATURATION_ADJUST:
+ meta->saturation = (file.extended_data[i]+2)*3/4;
break;
+ case X3F_EXTENDED_DATA_EXPOSURE_ADJUST:
+ meta->exposure = (file.extended_data[i]+2)*3/4;
+ break;
+ case X3F_EXTENDED_DATA_CONTRAST_ADJUST:
+ /* Ok, SPP assume the range is from -2 to 2
+ but RS expect a range from 0 to 3
+ Also 0 in RS means no contrast, as -2 in SPP means
+ half contrast (equivalent for 3 and 2*/
+ meta->contrast = (file.extended_data[i]+2)*1.5/4;
+ break;
+ case X3F_EXTENDED_DATA_SHARPNESS_ADJUST:
+ if (file.extended_data[i]>0)
+ meta->sharpness = (file.extended_data[i]+2)*10/4;
+ break;
default:
break;
}
@@ -277,6 +302,14 @@
pixbuf = gdk_pixbuf_new_from_data(raw_get_map(rawfile)+start, GDK_COLORSPACE_RGB, FALSE, 8,
width, height, rowstride, NULL, NULL);
+ if (file.rotation > 0)
+ {
+ /* gdk_pixbuf_rotate_simple rotates trigonometric */
+ pixbuf2=gdk_pixbuf_rotate_simple(pixbuf,360-file.rotation);
+ g_object_unref(pixbuf);
+ pixbuf=pixbuf2;
+ }
+
if (pixbuf)
{
ratio = ((gdouble) gdk_pixbuf_get_width(pixbuf))/((gdouble) gdk_pixbuf_get_height(pixbuf));
@@ -291,3 +324,29 @@
raw_close_file(rawfile);
return;
}
+
+/* DCraw does not read the rotation field stored in the x3f file so we
+ should take care of this */
+
+RS_IMAGE16 *rs_image16_open_x3f(const gchar *filename,
+ gboolean half_size)
+{
+ RS_IMAGE16 *photo;
+ RAWFILE *rawfile;
+ guint rotation;
+
+ rawfile = raw_open_file(filename);
+ if (!rawfile) return(NULL);
+ if (!raw_strcmp(rawfile, 0, "FOVb", 4))
+ {
+ raw_close_file(rawfile);
+ return(NULL);
+ }
+
+ raw_set_byteorder(rawfile, 0x4949); /* x3f is always little endian */
+ raw_get_uint(rawfile,36,&rotation);
+ raw_close_file(rawfile);
+ photo=rs_image16_open_dcraw(filename,half_size);
+ rs_image16_orientation(photo, rotation/90);
+ return photo;
+}
diff -urN rawstudio-svn2079.orig/src/x3f-meta.h rawstudio-svn2079/src/x3f-meta.h
--- rawstudio-svn2079.orig/src/x3f-meta.h 2008-10-28 04:15:03.000000000 +0100
+++ rawstudio-svn2079/src/x3f-meta.h 2008-11-27 01:13:01.000000000 +0100
@@ -18,3 +18,4 @@
*/
extern void rs_x3f_load_meta(const gchar *filename, RSMetadata *meta);
+RS_IMAGE16 *rs_image16_open_x3f(const gchar *filename, gboolean half_size);
_______________________________________________
Rawstudio-dev mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-dev