mirror of
https://github.com/nothings/stb
synced 2025-03-05 18:41:25 +03:00
Merge branch 'stb_image_write_mscrt_errors' of https://github.com/xeekworx/stb
This commit is contained in:
commit
faf08e0018
@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
Will probably not work correctly with strict-aliasing optimizations.
|
Will probably not work correctly with strict-aliasing optimizations.
|
||||||
|
|
||||||
|
If using a modern Microsoft Compiler, non-safe versions of CRT calls may cause
|
||||||
|
compilation warnings or even errors. To avoid this, also before #including,
|
||||||
|
|
||||||
|
#define STBI_MSC_SECURE_CRT
|
||||||
|
|
||||||
ABOUT:
|
ABOUT:
|
||||||
|
|
||||||
This header file is a library for writing images to C stdio. It could be
|
This header file is a library for writing images to C stdio. It could be
|
||||||
@ -265,7 +270,12 @@ static void stbi__stdio_write(void *context, void *data, int size)
|
|||||||
|
|
||||||
static int stbi__start_write_file(stbi__write_context *s, const char *filename)
|
static int stbi__start_write_file(stbi__write_context *s, const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(filename, "wb");
|
FILE *f;
|
||||||
|
#ifdef STBI_MSC_SECURE_CRT
|
||||||
|
fopen_s(&f, filename, "wb");
|
||||||
|
#else
|
||||||
|
f = fopen(filename, "wb");
|
||||||
|
#endif
|
||||||
stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);
|
stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);
|
||||||
return f != NULL;
|
return f != NULL;
|
||||||
}
|
}
|
||||||
@ -668,7 +678,11 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f
|
|||||||
char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
|
char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
|
||||||
s->func(s->context, header, sizeof(header)-1);
|
s->func(s->context, header, sizeof(header)-1);
|
||||||
|
|
||||||
|
#ifdef STBI_MSC_SECURE_CRT
|
||||||
|
len = sprintf_s(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
|
||||||
|
#else
|
||||||
len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
|
len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
|
||||||
|
#endif
|
||||||
s->func(s->context, buffer, len);
|
s->func(s->context, buffer, len);
|
||||||
|
|
||||||
for(i=0; i < y; i++)
|
for(i=0; i < y; i++)
|
||||||
@ -1086,7 +1100,11 @@ STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const
|
|||||||
int len;
|
int len;
|
||||||
unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);
|
unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);
|
||||||
if (png == NULL) return 0;
|
if (png == NULL) return 0;
|
||||||
|
#ifdef STBI_MSC_SECURE_CRT
|
||||||
|
fopen_s(&f, filename, "wb");
|
||||||
|
#else
|
||||||
f = fopen(filename, "wb");
|
f = fopen(filename, "wb");
|
||||||
|
#endif
|
||||||
if (!f) { STBIW_FREE(png); return 0; }
|
if (!f) { STBIW_FREE(png); return 0; }
|
||||||
fwrite(png, 1, len, f);
|
fwrite(png, 1, len, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user