Hi,
I wanted to see exposure compensation (bias) data along with the other Exif
data in RS and while implementing that I added code for handling some of the
unimplemented TIFF6.0 data types. I've attached a patch based on r4025. I
have not tried the data types beside the SRATIONAL type I needed for
exposure compensation and I have certainly not tested anything rigorously.
The exposure compensation is only implemented in the meta-tiff plugin and I
have only tested with files from my Canon 1Ds mk1. If there are raw files
taken with exposure compensation available for other cameras and it's a
feature you think should be in RS, I can look at implementing it for other
meta plugins, cameras and what not, but I'm new to this project and would
probably need a little guidance :-)
Regards,
Erik Wognsen
Index: plugins/meta-tiff/tiff-meta.c
===================================================================
51a52
> gchar value_char;
52a54
> gshort value_short;
53a56
> gint value_int;
54a58,60
> gdouble value_srational;
> gfloat value_float;
> gdouble value_double;
110a117
> // why not use raw_get_rational in here? -erw, 2011-09-07
121a129,145
> /**
> * Get a TIFF_FIELD_TYPE_SRATIONAL value from a TIFF file
> */
> static gfloat
> get_srational(RAWFILE *rawfile, guint offset)
> {
> gint int1=0, int2=1;
> if (!raw_get_int(rawfile, offset, &int1))
> return 0;
> if (!raw_get_int(rawfile, offset+4, &int2))
> return 0;
>
> if (int2 == 0)
> return 0;
> return ((gdouble) int1) / ((gdouble) int2);
> }
>
148a173
> /* case TIFF_FIELD_TYPE_ASCII: TODO? */
158c183
< ifd->value_rational = get_rational(rawfile, ifd->value_offset);
---
> ifd->value_rational = get_rational(rawfile, ifd->value_offset);
160a186,210
> case TIFF_FIELD_TYPE_SBYTE:
> raw_get_char(rawfile, offset+8, &ifd->value_char);
> ifd->value = ifd->value_char;
> break;
> /* case TIFF_FIELD_TYPE_UNDEFINED: TODO? */
> case TIFF_FIELD_TYPE_SSHORT:
> raw_get_short(rawfile, offset+8, &ifd->value_short);
> ifd->value = ifd->value_short;
> break;
> case TIFF_FIELD_TYPE_SLONG:
> raw_get_int(rawfile, offset+8, &ifd->value_int);
> ifd->value = ifd->value_int;
> break;
> case TIFF_FIELD_TYPE_SRATIONAL:
> ifd->value_srational = get_srational(rawfile, ifd->value_offset);
> ifd->value = ifd->value_srational;
> break;
> case TIFF_FIELD_TYPE_FLOAT:
> raw_get_float(rawfile, offset+8, &ifd->value_float);
> ifd->value = ifd->value_float;
> break;
> case TIFF_FIELD_TYPE_DOUBLE:
> raw_get_double(rawfile, offset+8, &ifd->value_double);
> ifd->value = ifd->value_double;
> break;
162d211
< /* FIXME: Implement types from TIFF 6.0 */
291c340
< case 0x4001: /* white balance for mulpiple Canon cameras */
---
> case 0x4001: /* white balance for multiple Canon cameras */
1391a1441,1444
> case 0x9204: /* ExposureBiasValue */
> if (ifd.count == 1)
> meta->exposurebias = ifd.value_srational;
> break;
1392a1446
> // Is it on purpose not to check idf.count here? -erw, 2011-09-07
Index: src/rs-store.c
===================================================================
682a683,685
>
> if (metadata->exposurebias != 0.0)
> g_string_append_printf(store->tooltip_text, _("<b>Exposure compensation</b>: %+.1fEV\n"), metadata->exposurebias);
Index: librawstudio/rs-rawfile.c
===================================================================
74a75,86
> raw_get_int(RAWFILE *rawfile, guint pos, gint *target)
> {
> if((rawfile->base+pos+4)>rawfile->size)
> return(FALSE);
> if (rawfile->byteorder == cpuorder)
> *target = *(gint *)(rawfile->map+pos+rawfile->base);
> else
> *target = ENDIANSWAP4(*(gint *)(rawfile->map+pos+rawfile->base));
> return(TRUE);
> }
>
> gboolean
127d138
<
135a147,158
> raw_get_double(RAWFILE *rawfile, guint pos, gdouble *target)
> {
> if((rawfile->base+pos+8)>rawfile->size)
> return(FALSE);
> if (rawfile->byteorder == cpuorder)
> *target = *(gdouble *)(rawfile->map+rawfile->base+pos);
> else
> *target = (gdouble) (ENDIANSWAP8(*(gint64 *)(rawfile->map+rawfile->base+pos)));
> return(TRUE);
> }
>
> gboolean
141a165,174
> return(TRUE);
> }
>
> gboolean
> raw_get_char(RAWFILE *rawfile, guint pos, gchar *target)
> {
> if((rawfile->base+pos+1)>rawfile->size)
> return(FALSE);
>
> *target = *(gchar *)(rawfile->map+rawfile->base+pos);
Index: librawstudio/rs-rawfile.h
===================================================================
22,23c22,24
< #define ENDIANSWAP4(a) (((a) & 0x000000FF) << 24 | ((a) & 0x0000FF00) << 8 | ((a) & 0x00FF0000) >> 8) | (((a) & 0xFF000000) >> 24)
< #define ENDIANSWAP2(a) (((a) & 0x00FF) << 8) | (((a) & 0xFF00) >> 8)
---
> #define ENDIANSWAP8(a) (((a) & 0x00000000000000FF) << 56 | ((a) & 0x000000000000FF00) << 40 | ((a) & 0x0000000000FF0000) << 24 | ((a) & 0x00000000FF000000) << 8 | ((a) & 0x000000FF00000000) >> 8 | ((a) & 0x0000FF0000000000) >> 24 | ((a) & 0x00FF000000000000) >> 40 | ((a) & 0xFF00000000000000) >> 56)
> #define ENDIANSWAP4(a) (((a) & 0x000000FF) << 24 | ((a) & 0x0000FF00) << 8 | ((a) & 0x00FF0000) >> 8 | ((a) & 0xFF000000) >> 24)
> #define ENDIANSWAP2(a) (((a) & 0x00FF) << 8 | ((a) & 0xFF00) >> 8)
31a33
> gboolean raw_get_int(RAWFILE *rawfile, guint pos, gint *target);
36a39
> gboolean raw_get_double(RAWFILE *rawfile, guint pos, gdouble *target);
37a41
> gboolean raw_get_char(RAWFILE *rawfile, guint pos, gchar *target);
Index: librawstudio/rs-metadata.c
===================================================================
84a85
> metadata->exposurebias = -999.0;
159a161,162
> if (metadata->exposurebias != -999.0)
> xmlTextWriterWriteFormatElement(writer, BAD_CAST "exposurebias", "%f", metadata->exposurebias);
288a292,297
> else if ((!xmlStrcmp(cur->name, BAD_CAST "exposurebias")))
> {
> val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
> metadata->exposurebias = rs_atof((gchar *) val);
> xmlFree(val);
> }
542a552,553
> if (metadata->exposurebias!=0.0)
> g_string_append_printf(label, _("%+.1fEV "), metadata->exposurebias);
Index: librawstudio/rs-metadata.h
===================================================================
66a67
> gfloat exposurebias;
_______________________________________________
Rawstudio-dev mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-dev