summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-02 21:45:56 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-03 04:32:50 +0300
commit2223579dfee2b40c5a483f087949a1ee3d49cd60 (patch)
tree33918af586672a4c5d2e9a10ac58d2e1b4cd473f
parent319fc87ef1432f3da8f9cb52a0d2e00d0626e69b (diff)
qcam: dng_writer: Generate thumbnail in RGB format
While the DNG specification supports greyscale ("BlackIsZero") for thumbnails, RawTherapee seems to have trouble reading them. Generate thumbnails in RGB instead (but still with greyscale content, to avoid having to interpolate colour components). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r--src/qcam/dng_writer.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp
index d04a8e16..bc1a63e6 100644
--- a/src/qcam/dng_writer.cpp
+++ b/src/qcam/dng_writer.cpp
@@ -74,7 +74,10 @@ void thumbScanlineSBGGRxxP(const FormatInfo &info, void *output,
unsigned int skip = info.bitsPerSample * 16 / 8;
for (unsigned int x = 0; x < width; x++) {
- *out++ = (in[0] + in[1] + in[stride] + in[stride + 1]) >> 2;
+ uint8_t value = (in[0] + in[1] + in[stride] + in[stride + 1]) >> 2;
+ *out++ = value;
+ *out++ = value;
+ *out++ = value;
in += skip;
}
}
@@ -175,16 +178,17 @@ int DNGWriter::write(const char *filename, const Camera *camera,
TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
/*
- * Thumbnail-specific tags. The thumbnail is stored as a greyscale image
- * with 1/16 of the raw image resolution.
+ * Thumbnail-specific tags. The thumbnail is stored as an RGB image
+ * with 1/16 of the raw image resolution. Greyscale would save space,
+ * but doesn't seem well supported by RawTherapee.
*/
TIFFSetField(tif, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, config.size.width / 16);
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, config.size.height / 16);
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
- TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);
+ TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
+ TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3);
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);