Merge branch 'master' of https://github.com/ab-cpp/stb into working
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sean Barrett · committed by Sean Barrett · parents 476c1f8, eee50c0 · Browse files · 2 files·+8 added−6 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+8 added−6 removed
- other:+8 added−6 removed
Provenance
- Commit
d1252e1- Tree
55725bd- Author
Sean Barrett <sean@nothings.org>- Committer
Sean Barrett <sean@nothings.org>- Parent 1
476c1f8- Parent 2
eee50c0
2 files changed+8 added−6 removed
modified:stb_image_write.h+6 added-6 removed
1066 unmodified lines1067 }1068 }1069 }1070 1071-unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)1071+unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)1072 {1073 int force_filter = stbi_write_force_png_filter;1074 int ctype[5] = { -1, 0, 4, 2, 6 };1075 unsigned char sig[8] = { 137,80,78,71,13,10,26,10 };13 unmodified lines1089 for (j=0; j < y; ++j) {1090 int filter_type;1091 if (force_filter > -1) {1092 filter_type = force_filter;1093- stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, force_filter, line_buffer);1093+ stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);1094 } else { // Estimate the best filter by running through all of them:1095 int best_filter = 0, best_filter_val = 0x7fffffff, est, i;1096 for (filter_type = 0; filter_type < 5; filter_type++) {1097- stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, filter_type, line_buffer);1097+ stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);1098 1099 // Estimate the entropy of the line using this filter; the less, the better.1100 est = 0;1101 for (i = 0; i < x*n; ++i) {4 unmodified lines1106 best_filter = filter_type;1107 }1108 }1109 if (filter_type != best_filter) { // If the last iteration already got us the best filter, don't redo it1110- stbiw__encode_png_line(pixels, stride_bytes, x, y, j, n, best_filter, line_buffer);1110+ stbiw__encode_png_line(const_cast<unsigned char*>(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);1111 filter_type = best_filter;1112 }1113 }1114 // when we get here, filter_type contains the filter type, and line_buffer contains the data43 unmodified lines1158 STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)1159 {1160 FILE *f;1161 int len;1162- unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);1162+ unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);1163 if (png == NULL) return 0;1164 1165 f = stbiw__fopen(filename, "wb");1166 if (!f) { STBIW_FREE(png); return 0; }6 unmodified lines1173 1174 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)1175 {1176 int len;1177- unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);1177+ unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);1178 if (png == NULL) return 0;1179 func(context, png, len);1180 STBIW_FREE(png);1181 return 1;435 unmodified linesmodified:stb_image.h+2 added
6384 unmodified lines6385 // this function is designed to support animated gifs, although stb_image doesn't support it6386 // two back is the image from two frames ago, used for a very specific disposal format6387 static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)6388 {6389+ STBI_NOTUSED(req_comp);6390 int dispose; 6391 int first_frame; 6392 int pi; 6393 int pcount; 216 unmodified lines6610 }6611 6612 static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)6613 {6614+ STBI_NOTUSED(ri);6615 stbi_uc *u = 0;6616 stbi__gif g;6617 memset(&g, 0, sizeof(g));6618 894 unmodified lines