From 7e989db555e3acba73db2dc162856ff6dcb9b7b9 Mon Sep 17 00:00:00 2001 From: themanagainstthetank <2011301000007@whu.edu.cn> Date: Mon, 16 Jan 2017 18:12:31 +0800 Subject: [PATCH 1/3] update stb_image.h int raw_data[4] to 0, or the compiler bugs --- stb_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stb_image.h b/stb_image.h index 5b334f6..3940f38 100644 --- a/stb_image.h +++ b/stb_image.h @@ -5375,7 +5375,7 @@ static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req unsigned char *tga_data; unsigned char *tga_palette = NULL; int i, j; - unsigned char raw_data[4]; + unsigned char raw_data[4] = {0}; int RLE_count = 0; int RLE_repeating = 0; int read_next_pixel = 1; From 552c548a0e6b978ba329e2702d7713327b40fd74 Mon Sep 17 00:00:00 2001 From: Jeremy Sawicki Date: Thu, 2 Mar 2017 18:06:10 -0800 Subject: [PATCH 2/3] stb_image: JPEG: Convert RGB to grayscale properly --- stb_image.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/stb_image.h b/stb_image.h index 3940f38..b3944b5 100644 --- a/stb_image.h +++ b/stb_image.h @@ -3596,7 +3596,7 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp // determine actual number of components to generate n = req_comp ? req_comp : z->s->img_n; - if (z->s->img_n == 3 && n < 3) + if (z->s->img_n == 3 && n < 3 && z->rgb != 3) decode_n = 1; else decode_n = z->s->img_n; @@ -3674,11 +3674,19 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp out += n; } } else { - stbi_uc *y = coutput[0]; - if (n == 1) - for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; - else - for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; + if (z->rgb == 3) { + for (i=0; i < z->s->img_x; ++i) { + out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + out[1] = 255; + out += n; + } + } else { + stbi_uc *y = coutput[0]; + if (n == 1) + for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; + else + for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; + } } } stbi__cleanup_jpeg(z); From cb7ffb2408ca11fd05a13f9dff658911e7aaa050 Mon Sep 17 00:00:00 2001 From: Jeremy Sawicki Date: Thu, 2 Mar 2017 18:19:21 -0800 Subject: [PATCH 3/3] stb_image: Update contributors --- stb_image.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stb_image.h b/stb_image.h index b3944b5..ed11d38 100644 --- a/stb_image.h +++ b/stb_image.h @@ -192,7 +192,7 @@ Ryamond Barbiero Paul Du Bois Engin Manap github:snagar Michaelangel007@github Oriol Ferrer Mesia Dale Weiler github:Zelex Philipp Wiesemann Josh Tobin github:rlyeh github:grim210@github - Blazej Dariusz Roszkowski github:sammyhw + Blazej Dariusz Roszkowski github:sammyhw Jeremy Sawicki LICENSE