get rid of unused return value from write callback

pull/177/head
Sean Barrett 2015-09-14 05:57:42 -07:00
parent b4477803cb
commit 93b2b82996
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* stb_image_write - v1.00 - public domain - http://nothings.org/stb/stb_image_write.h
writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010
writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010-2015
no warranty implied; use at your own risk
Before #including,
@ -44,6 +44,9 @@ USAGE:
int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);
int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);
where the callback is:
void stbi_write_func(void *context, void *data, int size);
You can define STBI_WRITE_NO_STDIO to disable the file variant of these
functions, so the library will not use stdio.h at all. However, this will
also disable HDR writing, because it requires stdio for formatted output.
@ -125,7 +128,7 @@ STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const
STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
#endif
typedef int stbi_write_func(void *context, void *data, int size);
typedef void stbi_write_func(void *context, void *data, int size);
STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data, int stride_in_bytes);
STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void *data);
@ -192,15 +195,15 @@ static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func
#ifndef STBI_WRITE_NO_STDIO
static int stbi__stdio_write(void *user, void *data, int size)
static void stbi__stdio_write(void *context, void *data, int size)
{
return (int) fwrite(data,1,size,(FILE*) user);
fwrite(data,1,size,(FILE*) context);
}
static int stbi__start_write_file(stbi__write_context *s, const char *filename)
{
FILE *f = fopen(filename, "wb");
stbi__start_write_callbacks(s, &stbi__stdio_write, (void *) f);
stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);
return f != NULL;
}

View File

@ -53,7 +53,7 @@ void test_ycbcr(void)
float hdr_data[200][200][3];
void dummy(void *context, void *data, int len)
void dummy_write(void *context, void *data, int len)
{
static char dummy[1024];
if (len > 1024) len = 1024;
@ -97,6 +97,9 @@ int main(int argc, char **argv)
stbi_write_png(stb_sprintf("output/%s.png", fname), w, h, 4, data, w*4);
stbi_write_bmp(stb_sprintf("output/%s.bmp", fname), w, h, 4, data);
stbi_write_tga(stb_sprintf("output/%s.tga", fname), w, h, 4, data);
stbi_write_png_to_func(dummy_write,0, w, h, 4, data, w*4);
stbi_write_bmp_to_func(dummy_write,0, w, h, 4, data);
stbi_write_tga_to_func(dummy_write,0, w, h, 4, data);
free(data);
} else
printf("FAILED 4\n");