fix stbir__linear_to_srgb_uchar:

1. table stored threshhold of transition from i to i+1, but wants to be i-1 to i
    2. table was computed by dividing uchar by 256.0 instead of 255.0, causing it to be 100% wrong
This commit is contained in:
Sean Barrett
2014-09-11 02:05:53 -07:00
parent 30c7a981ec
commit 16d68d14f8
2 changed files with 50 additions and 56 deletions

View File

@ -810,20 +810,21 @@ void test_suite(int argc, char **argv)
}
#endif
#if 0 // linear_to_srgb_uchar table
for (i=0; i < 256; ++i) {
float f = stbir__srgb_to_linear((i-0.5f)/255.0f);
printf("%9d, ", (int) ((f) * (1<<28)));
if ((i & 7) == 7)
printf("\n");
}
#endif
for (i = 0; i < 256; i++) {
float f = stbir__srgb_to_linear(float(i) / 255);
int n = stbir__linear_to_srgb_uchar(f);
STBIR_ASSERT(n == i);
}
#if 0 // linear_to_srgb_uchar table
for (i=0; i < 256; ++i) {
float f = stbir__srgb_to_linear((i+0.5f)/256.0f);
printf("%9d, ", (int) ((f) * (1<<28)));
if ((i & 7) == 7)
printf("\n");
}
#endif
test_filters();