From f2b0f5fe1c7db69d66723e7352b056bcfc0f0c2c Mon Sep 17 00:00:00 2001 From: John Bowler Date: Sat, 19 Apr 2025 08:58:09 -0700 Subject: [PATCH] fix(mDCv): Correct the floating-point setter `png_set_mDCv` In the floating-point API function `png_set_mDCv` we incorrectly divided by two the chromaticity values before passing them on to `png_set_mDCv_fixed`. Reported-by: Mohit Bakshi Signed-off-by: John Bowler Signed-off-by: Cosmin Truta --- pngset.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/pngset.c b/pngset.c index d7f3393c4..3e63c2724 100644 --- a/pngset.c +++ b/pngset.c @@ -300,17 +300,14 @@ png_set_mDCV(png_const_structrp png_ptr, png_inforp info_ptr, double maxDL, double minDL) { png_set_mDCV_fixed(png_ptr, info_ptr, - /* The ITU approach is to scale by 50,000, not 100,000 so just divide - * the input values by 2 and use png_fixed: - */ - png_fixed(png_ptr, white_x / 2, "png_set_mDCV(white(x))"), - png_fixed(png_ptr, white_y / 2, "png_set_mDCV(white(y))"), - png_fixed(png_ptr, red_x / 2, "png_set_mDCV(red(x))"), - png_fixed(png_ptr, red_y / 2, "png_set_mDCV(red(y))"), - png_fixed(png_ptr, green_x / 2, "png_set_mDCV(green(x))"), - png_fixed(png_ptr, green_y / 2, "png_set_mDCV(green(y))"), - png_fixed(png_ptr, blue_x / 2, "png_set_mDCV(blue(x))"), - png_fixed(png_ptr, blue_y / 2, "png_set_mDCV(blue(y))"), + png_fixed(png_ptr, white_x, "png_set_mDCV(white(x))"), + png_fixed(png_ptr, white_y, "png_set_mDCV(white(y))"), + png_fixed(png_ptr, red_x, "png_set_mDCV(red(x))"), + png_fixed(png_ptr, red_y, "png_set_mDCV(red(y))"), + png_fixed(png_ptr, green_x, "png_set_mDCV(green(x))"), + png_fixed(png_ptr, green_y, "png_set_mDCV(green(y))"), + png_fixed(png_ptr, blue_x, "png_set_mDCV(blue(x))"), + png_fixed(png_ptr, blue_y, "png_set_mDCV(blue(y))"), png_fixed_ITU(png_ptr, maxDL, "png_set_mDCV(maxDL)"), png_fixed_ITU(png_ptr, minDL, "png_set_mDCV(minDL)")); }