Update to STB conventions
This commit is contained in:
parent
ccc4b3716a
commit
eee50c079d
@ -6336,8 +6336,9 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
|
|||||||
|
|
||||||
// this function is designed to support animated gifs, although stb_image doesn't support it
|
// this function is designed to support animated gifs, although stb_image doesn't support it
|
||||||
// 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, 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;
|
||||||
@ -6560,8 +6561,9 @@ 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 *)
|
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));
|
||||||
|
@ -985,14 +985,14 @@ static unsigned char stbiw__paeth(int a, int b, int c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @OPTIMIZE: provide an option that always forces left-predict or paeth predict
|
// @OPTIMIZE: provide an option that always forces left-predict or paeth predict
|
||||||
static void stbiw__encode_png_line(const unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer)
|
static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer)
|
||||||
{
|
{
|
||||||
static int mapping[] = { 0,1,2,3,4 };
|
static int mapping[] = { 0,1,2,3,4 };
|
||||||
static int firstmap[] = { 0,1,0,5,6 };
|
static int firstmap[] = { 0,1,0,5,6 };
|
||||||
int *mymap = (y != 0) ? mapping : firstmap;
|
int *mymap = (y != 0) ? mapping : firstmap;
|
||||||
int i;
|
int i;
|
||||||
int type = mymap[filter_type];
|
int type = mymap[filter_type];
|
||||||
const unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);
|
unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);
|
||||||
int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;
|
int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -1040,11 +1040,11 @@ unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_byt
|
|||||||
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;
|
||||||
@ -1057,7 +1057,7 @@ unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_byt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user