From patchwork Sat May 2 22:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3676 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EB9D6162E for ; Sun, 3 May 2020 00:57:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="d1aoB6+j"; dkim-atps=neutral Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 023F472C for ; Sun, 3 May 2020 00:57:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1588460232; bh=WBjePhcF60gvK3H85ZX8vDSpxEG6HKuCVjORCGZbi4A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=d1aoB6+jD7ZS0Qqc9dEy7/AsguLM7uiEBsoz5c4zcUn9Sz3NvF79jq8vpRBLrEEiL kTW2v+CLlmLRPu2hVL4+yc4zMGa4II0ya2N3QZqDmU729AyA3Pen8pScqCw1Wsh2vS IGUh5SKbArfiflDigugFLfIud/EEmXfmxS4GT/Zo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 3 May 2020 01:57:04 +0300 Message-Id: <20200502225704.2911-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.25.3 In-Reply-To: <20200502225704.2911-1-laurent.pinchart@ideasonboard.com> References: <20200502225704.2911-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] qcam: dng_writer: Generate thumbnail in RGB format X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 May 2020 22:57:13 -0000 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 Reviewed-by: Niklas Söderlund --- src/qcam/dng_writer.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index d04a8e161218..bc1a63e69799 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);