|
|
|
@ -201,10 +201,11 @@ |
|
|
|
|
Janez Zemva John Bartholomew Michal Cichon svdijk@github |
|
|
|
|
Jonathan Blow Ken Hamada Tero Hanninen Baldur Karlsson |
|
|
|
|
Laurent Gomila Cort Stratton Sergio Gonzalez romigrou@github |
|
|
|
|
Aruelien Pocheville Thibault Reuille Cass Everitt |
|
|
|
|
Aruelien Pocheville Thibault Reuille Cass Everitt
|
|
|
|
|
Ryamond Barbiero Paul Du Bois Engin Manap |
|
|
|
|
Michaelangel007@github Oriol Ferrer Mesia |
|
|
|
|
Blazej Dariusz Roszkowski |
|
|
|
|
Michaelangel007@github |
|
|
|
|
Oriol Ferrer Mesia |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE |
|
|
|
@ -3425,10 +3426,13 @@ static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp |
|
|
|
|
|
|
|
|
|
static unsigned char *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) |
|
|
|
|
{ |
|
|
|
|
stbi__jpeg j; |
|
|
|
|
j.s = s; |
|
|
|
|
stbi__setup_jpeg(&j); |
|
|
|
|
return load_jpeg_image(&j, x,y,comp,req_comp); |
|
|
|
|
unsigned char* result; |
|
|
|
|
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); |
|
|
|
|
j->s = s; |
|
|
|
|
stbi__setup_jpeg(j); |
|
|
|
|
result = load_jpeg_image(j, x,y,comp,req_comp); |
|
|
|
|
STBI_FREE(j); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int stbi__jpeg_test(stbi__context *s) |
|
|
|
@ -3456,9 +3460,12 @@ static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) |
|
|
|
|
|
|
|
|
|
static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) |
|
|
|
|
{ |
|
|
|
|
stbi__jpeg j; |
|
|
|
|
j.s = s; |
|
|
|
|
return stbi__jpeg_info_raw(&j, x, y, comp); |
|
|
|
|
int result; |
|
|
|
|
stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); |
|
|
|
|
j->s = s; |
|
|
|
|
result = stbi__jpeg_info_raw(j, x, y, comp); |
|
|
|
|
STBI_FREE(j); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
@ -3749,7 +3756,7 @@ static int stbi__compute_huffman_codes(stbi__zbuf *a) |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int stbi__parse_uncomperssed_block(stbi__zbuf *a) |
|
|
|
|
static int stbi__parse_uncompressed_block(stbi__zbuf *a) |
|
|
|
|
{ |
|
|
|
|
stbi_uc header[4]; |
|
|
|
|
int len,nlen,k; |
|
|
|
@ -3815,7 +3822,7 @@ static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) |
|
|
|
|
final = stbi__zreceive(a,1); |
|
|
|
|
type = stbi__zreceive(a,2); |
|
|
|
|
if (type == 0) { |
|
|
|
|
if (!stbi__parse_uncomperssed_block(a)) return 0; |
|
|
|
|
if (!stbi__parse_uncompressed_block(a)) return 0; |
|
|
|
|
} else if (type == 3) { |
|
|
|
|
return 0; |
|
|
|
|
} else { |
|
|
|
@ -5447,6 +5454,21 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (channelCount >= 3) { |
|
|
|
|
for (i=0; i < w*h; ++i) { |
|
|
|
|
unsigned char *pixel = out + 4*i; |
|
|
|
|
if (pixel[3] != 0 && pixel[3] != 255) { |
|
|
|
|
// remove weird white matte from PSD
|
|
|
|
|
float a = pixel[3] / 255.0f; |
|
|
|
|
float ra = 1.0f / a; |
|
|
|
|
float inv_a = 255.0f * (1 - ra); |
|
|
|
|
pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); |
|
|
|
|
pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); |
|
|
|
|
pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (req_comp && req_comp != 4) { |
|
|
|
|
out = stbi__convert_format(out, 4, req_comp, w, h); |
|
|
|
|
if (out == NULL) return out; // stbi__convert_format frees input on failure
|
|
|
|
@ -5759,13 +5781,15 @@ static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_in |
|
|
|
|
|
|
|
|
|
static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) |
|
|
|
|
{ |
|
|
|
|
stbi__gif g; |
|
|
|
|
if (!stbi__gif_header(s, &g, comp, 1)) { |
|
|
|
|
stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); |
|
|
|
|
if (!stbi__gif_header(s, g, comp, 1)) { |
|
|
|
|
STBI_FREE(g); |
|
|
|
|
stbi__rewind( s ); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
if (x) *x = g.w; |
|
|
|
|
if (y) *y = g.h; |
|
|
|
|
if (x) *x = g->w; |
|
|
|
|
if (y) *y = g->h; |
|
|
|
|
STBI_FREE(g); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -6018,20 +6042,20 @@ static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, i |
|
|
|
|
static stbi_uc *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) |
|
|
|
|
{ |
|
|
|
|
stbi_uc *u = 0; |
|
|
|
|
stbi__gif g; |
|
|
|
|
memset(&g, 0, sizeof(g)); |
|
|
|
|
stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); |
|
|
|
|
memset(g, 0, sizeof(*g)); |
|
|
|
|
|
|
|
|
|
u = stbi__gif_load_next(s, &g, comp, req_comp); |
|
|
|
|
u = stbi__gif_load_next(s, g, comp, req_comp); |
|
|
|
|
if (u == (stbi_uc *) s) u = 0; // end of animated gif marker
|
|
|
|
|
if (u) { |
|
|
|
|
*x = g.w; |
|
|
|
|
*y = g.h; |
|
|
|
|
*x = g->w; |
|
|
|
|
*y = g->h; |
|
|
|
|
if (req_comp && req_comp != 4) |
|
|
|
|
u = stbi__convert_format(u, 4, req_comp, g.w, g.h); |
|
|
|
|
u = stbi__convert_format(u, 4, req_comp, g->w, g->h); |
|
|
|
|
} |
|
|
|
|
else if (g.out) |
|
|
|
|
STBI_FREE(g.out); |
|
|
|
|
|
|
|
|
|
else if (g->out) |
|
|
|
|
STBI_FREE(g->out); |
|
|
|
|
STBI_FREE(g); |
|
|
|
|
return u; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|