Merge branch 'master' of https://github.com/ab-cpp/stb into working
This commit is contained in:
commit
d1252e1bb9
@ -6386,6 +6386,7 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
|
|||||||
// two back is the image from two frames ago, used for a very specific disposal format
|
// two back is the image from two frames ago, used for a very specific disposal format
|
||||||
static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)
|
static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)
|
||||||
{
|
{
|
||||||
|
STBI_NOTUSED(req_comp);
|
||||||
int dispose;
|
int dispose;
|
||||||
int first_frame;
|
int first_frame;
|
||||||
int pi;
|
int pi;
|
||||||
@ -6610,6 +6611,7 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
|
|||||||
|
|
||||||
static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
|
static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
|
||||||
{
|
{
|
||||||
|
STBI_NOTUSED(ri);
|
||||||
stbi_uc *u = 0;
|
stbi_uc *u = 0;
|
||||||
stbi__gif g;
|
stbi__gif g;
|
||||||
memset(&g, 0, sizeof(g));
|
memset(&g, 0, sizeof(g));
|
||||||
|
@ -1068,7 +1068,7 @@ static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
|
unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
|
||||||
{
|
{
|
||||||
int force_filter = stbi_write_force_png_filter;
|
int force_filter = stbi_write_force_png_filter;
|
||||||
int ctype[5] = { -1, 0, 4, 2, 6 };
|
int ctype[5] = { -1, 0, 4, 2, 6 };
|
||||||
@ -1090,11 +1090,11 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
int filter_type;
|
int filter_type;
|
||||||
if (force_filter > -1) {
|
if (force_filter > -1) {
|
||||||
filter_type = force_filter;
|
filter_type = force_filter;
|
||||||
stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, force_filter, line_buffer);
|
stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);
|
||||||
} else { // Estimate the best filter by running through all of them:
|
} else { // Estimate the best filter by running through all of them:
|
||||||
int best_filter = 0, best_filter_val = 0x7fffffff, est, i;
|
int best_filter = 0, best_filter_val = 0x7fffffff, est, i;
|
||||||
for (filter_type = 0; filter_type < 5; filter_type++) {
|
for (filter_type = 0; filter_type < 5; filter_type++) {
|
||||||
stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, filter_type, line_buffer);
|
stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);
|
||||||
|
|
||||||
// Estimate the entropy of the line using this filter; the less, the better.
|
// Estimate the entropy of the line using this filter; the less, the better.
|
||||||
est = 0;
|
est = 0;
|
||||||
@ -1107,7 +1107,7 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it
|
if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it
|
||||||
stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, best_filter, line_buffer);
|
stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);
|
||||||
filter_type = best_filter;
|
filter_type = best_filter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1159,7 +1159,7 @@ STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const
|
|||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int len;
|
int len;
|
||||||
unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);
|
unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
|
||||||
if (png == NULL) return 0;
|
if (png == NULL) return 0;
|
||||||
|
|
||||||
f = stbiw__fopen(filename, "wb");
|
f = stbiw__fopen(filename, "wb");
|
||||||
@ -1174,7 +1174,7 @@ STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const
|
|||||||
STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)
|
STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);
|
unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
|
||||||
if (png == NULL) return 0;
|
if (png == NULL) return 0;
|
||||||
func(context, png, len);
|
func(context, png, len);
|
||||||
STBIW_FREE(png);
|
STBIW_FREE(png);
|
||||||
|
Loading…
Reference in New Issue
Block a user