From: Glenn Randers-P. <gl...@co...> - 2007-11-30 22:15:13
|
At 04:22 PM 11/30/2007 -0500, you wrote: > >Hi guys. > >I think that there is a bug in 1.2.23 pngset.c, png_set_cHRM_fixed() > >The arguments to the function should already be in fixed point. This >means two things to me. First, the section wrapped with > >#ifdef PNG_FLOATING_POINT_SUPPORTED > if (white_x > (double) PNG_UINT_31_MAX || > white_y > (double) PNG_UINT_31_MAX || > red_x > (double) PNG_UINT_31_MAX || > red_y > (double) PNG_UINT_31_MAX || > green_x > (double) PNG_UINT_31_MAX || > green_y > (double) PNG_UINT_31_MAX || > blue_x > (double) PNG_UINT_31_MAX || > blue_y > (double) PNG_UINT_31_MAX) >#else > >does not belong there and can be removed (again, the values should be in >fixed so the comparison does not make sense). OK. >Second, the test for: > png_warning(png_ptr, > "Ignoring attempt to set chromaticity value exceeding 21474.83"); >is wrong because it is not testing for that value..... > >instead of: >if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || > white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || > red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || > red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || > green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || > green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || > blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || > blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L) > >it should be: > if (white_x > (png_fixed_point) 2147483000L || > white_y > (png_fixed_point) 2147483000L || > red_x > (png_fixed_point) 2147483000L || > red_y > (png_fixed_point) 2147483000L || > green_x > (png_fixed_point) 2147483000L || > green_y > (png_fixed_point) 2147483000L || > blue_x > (png_fixed_point) 2147483000L || > blue_y > (png_fixed_point) 2147483000L) PNG_UINT_31_MAX is 2147483647, and the division should get optimized away by the compiler preprocessor. Glenn |