Skip to content

Commit 54a781d

Browse files
njhollinghurstnaushir
authored andcommitted
image: dng: Make thumbnail less dark
Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
1 parent 8b286cc commit 54a781d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

image/dng.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,10 @@ void dng_save(std::vector<libcamera::Span<uint8_t>> const &mem, StreamInfo const
280280
for (unsigned int x = 0; x < (info.width >> 4); x++)
281281
{
282282
unsigned int off = (y * info.width + x) << 4;
283-
int grey = buf[off] + buf[off + 1] + buf[off + info.width] + buf[off + info.width + 1];
284-
grey = white * sqrt(grey / (double)white); // fake "gamma"
285-
thumb_buf[3 * x] = thumb_buf[3 * x + 1] = thumb_buf[3 * x + 2] = grey >> (bayer_format.bits - 6);
283+
uint32_t grey = buf[off] + buf[off + 1] + buf[off + info.width] + buf[off + info.width + 1];
284+
grey = (grey << 14) >> bayer_format.bits;
285+
grey = sqrt((double)grey); // simple "gamma correction"
286+
thumb_buf[3 * x] = thumb_buf[3 * x + 1] = thumb_buf[3 * x + 2] = grey;
286287
}
287288
if (TIFFWriteScanline(tif, &thumb_buf[0], y, 0) != 1)
288289
throw std::runtime_error("error writing DNG thumbnail data");

0 commit comments

Comments
 (0)