From 8849501a3f2251068921d338f999019312906cad Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sat, 13 Sep 2014 08:21:14 -0700 Subject: [PATCH] add documentation explaining why even a 64K table for srgb_to_uint8 would be inaccurate --- stb_image_resize.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stb_image_resize.h b/stb_image_resize.h index 35ecae0..288f799 100644 --- a/stb_image_resize.h +++ b/stb_image_resize.h @@ -565,6 +565,10 @@ static float stbir__srgb_uchar_to_linear_float[256] = { }; // sRGB transition values, scaled by 1<<28 +// note that if you only scaled by 1<<16, all the values would be 4K smaller, +// so [1] would be ~10, and so that would have around 5% error (10 +- 0.5) +// at the boundary between uint8 0 and 1. This also means that a 64K-entry table +// would have the same 5% error there. static int stbir__srgb_offset_to_linear_scaled[256] = { 0, 40738, 122216, 203693, 285170, 366648, 448125, 529603,