Update to STB conventions
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Andrew Beatty · committed by Andrew Beatty · parent ccc4b37 · Browse files · 2 files·+9 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+9 added−7 removed
- other:+9 added−7 removed
Provenance
- Commit
eee50c0- Tree
6d0c7fe- Author
Andrew Beatty <abeatty@facegen.com>- Committer
Andrew Beatty <abeatty@facegen.com>- Parent
ccc4b37
2 files changed+9 added−7 removed
modified:stb_image_write.h+5 added-5 removed
983 unmodified lines984 return STBIW_UCHAR(c);985 }986 987 // @OPTIMIZE: provide an option that always forces left-predict or paeth predict988-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)988+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)989 {990 static int mapping[] = { 0,1,2,3,4 };991 static int firstmap[] = { 0,1,0,5,6 };992 int *mymap = (y != 0) ? mapping : firstmap;993 int i;994 int type = mymap[filter_type];995- const unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);995+ unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);996 int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;997 for (i = 0; i < n; ++i) {998 switch (type) {999 case 0: line_buffer[i] = z[i]; break;39 unmodified lines1039 for (j=0; j < y; ++j) {1040 int filter_type;1041 if (force_filter > -1) {1042 filter_type = force_filter;1043- stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, force_filter, line_buffer);1043+ stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);1044 } else { // Estimate the best filter by running through all of them:1045 int best_filter = 0, best_filter_val = 0x7fffffff, est, i;1046 for (filter_type = 0; filter_type < 5; filter_type++) {1047- stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, filter_type, line_buffer);1047+ stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);1048 1049 // Estimate the entropy of the line using this filter; the less, the better.1050 est = 0;1051 for (i = 0; i < x*n; ++i) {4 unmodified lines1056 best_filter = filter_type;1057 }1058 }1059 if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it1060- stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, best_filter, line_buffer);1060+ stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);1061 filter_type = best_filter;1062 }1063 }1064 // when we get here, filter_type contains the filter type, and line_buffer contains the data504 unmodified linesmodified:stb_image.h+4 added-2 removed
6334 unmodified lines6335 }6336 6337 // this function is designed to support animated gifs, although stb_image doesn't support it6338 // two back is the image from two frames ago, used for a very specific disposal format6339-static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int, stbi_uc *two_back)6339+static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)6340 {6341+ STBI_NOTUSED(req_comp);6342 int dispose; 6343 int first_frame; 6344 int pi; 6345 int pcount; 214 unmodified lines6560 return stbi__errpuc("not GIF", "Image was not as a gif type."); 6561 }6562 }6563 6563-static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *)6564+static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)6565 {6566+ STBI_NOTUSED(ri);6567 stbi_uc *u = 0;6568 stbi__gif g;6569 memset(&g, 0, sizeof(g));6570 894 unmodified lines