From 08851582676ca78dd6594396117f3d84f4768299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Mon, 29 Jan 2024 13:33:11 +0100 Subject: [PATCH] imageio: write WhiteLevel as rational instead of encoding Also, backward compatible version must be at 1.4 for float images. --- src/imageio/imageio_dng.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/imageio/imageio_dng.h b/src/imageio/imageio_dng.h index 5b2db7dfa856..4dd6f95f5095 100644 --- a/src/imageio/imageio_dng.h +++ b/src/imageio/imageio_dng.h @@ -193,16 +193,14 @@ static inline void _imageio_dng_write_tiff_header( else // bayer b = _imageio_dng_make_tag(EXIF_TAG_SENS_PATTERN, BYTE, 4, cfapattern, buf, b, &cnt); /* bayer PATTERN */ - b = _imageio_dng_make_tag(EXIF_TAG_VERSION, BYTE, 4, (1 << 24)|(2 << 16), buf, b, &cnt); - b = _imageio_dng_make_tag(EXIF_TAG_BACK_VERSION, BYTE, 4, (1 << 24)|(1 << 16), buf, b, &cnt); + b = _imageio_dng_make_tag(EXIF_TAG_VERSION, BYTE, 4, (1 << 24)|(4 << 16), buf, b, &cnt); + b = _imageio_dng_make_tag(EXIF_TAG_BACK_VERSION, BYTE, 4, (1 << 24)|(4 << 16), buf, b, &cnt); - union { - float f; - uint32_t u; - } white; - white.f = whitelevel; - - b = _imageio_dng_make_tag(EXIF_TAG_WHITE_LEVEL, LONG, 1, white.u, buf, b, &cnt); /* WhiteLevel in float, actually. */ + b = _imageio_dng_make_tag(EXIF_TAG_WHITE_LEVEL, RATIONAL, 1, data, buf, b, &cnt); /* WhiteLevel */ + den = 10000; + _imageio_dng_write_buf(buf, data, (int)roundf(whitelevel * den)); + _imageio_dng_write_buf(buf, data + 4, den); + data += 8; // ColorMatrix1 try to get camera matrix else m[k] like before if(dt_is_valid_colormatrix(adobe_XYZ_to_CAM[0][0]))