Skip to content
Myr

fix compiler warnings and const error

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 e6afb9c · Browse files · 2 files+7 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+7 added−7 removed

  • other:+7 added−7 removed

2 files+7 added−7 removed

modified:stb_image_write.h+5 added-5 removed
983 unmodified lines
984 return STBIW_UCHAR(c);985}986987// @OPTIMIZE: provide an option that always forces left-predict or paeth predict988static 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)988static 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)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 unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);995 const 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;
17 unmodified lines
1017 }1018 }1019}10201021unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)1021unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)1022{1023 int force_filter = stbi_write_force_png_filter;1024 int ctype[5] = { -1, 0, 4, 2, 6 };1025 unsigned char sig[8] = { 137,80,78,71,13,10,26,10 };
82 unmodified lines
1108STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)1109{1110 FILE *f;1111 int len;1112 unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);1112 unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);1113 if (png == NULL) return 0;1114#ifdef STBI_MSC_SECURE_CRT1115 if (fopen_s(&f, filename, "wb"))1116 f = NULL;
10 unmodified lines
11271128STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)1129{1130 int len;1131 unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);1131 unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);1132 if (png == NULL) return 0;1133 func(context, png, len);1134 STBIW_FREE(png);1135 return 1;
433 unmodified lines
modified:stb_image.h+2 added-2 removed
6334 unmodified lines
6335}63366337// 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 format6339static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)6339static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int, stbi_uc *two_back)6340{6341 int dispose; 6342 int first_frame; 6343 int pi;
215 unmodified lines
6559 return stbi__errpuc("not GIF", "Image was not as a gif type."); 6560 }6561}65626563static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)6563static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *)6564{6565 stbi_uc *u = 0;6566 stbi__gif g;6567 memset(&g, 0, sizeof(g));
895 unmodified lines