From aeb2b4b64de878ce76447ad4481ea6ef682ab4d4 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Sun, 11 Feb 2018 11:19:45 -0800 Subject: [PATCH] tweak handling of STBIWDEF --- stb_image_write.h | 17 ++++++++++++++--- tests/test_cpp_compilation.cpp | 4 +++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/stb_image_write.h b/stb_image_write.h index 3a75614..39befed 100644 --- a/stb_image_write.h +++ b/stb_image_write.h @@ -45,8 +45,8 @@ USAGE: int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data); int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data); + int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality); int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data); - int stbi_write_jpg(char const *filename, int w, int h, int comp, const float *data, int quality); void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically @@ -136,6 +136,8 @@ CREDITS: Cap Petschulat Simon Rodriguez Ivan Tikhonov + github:ignotion + Adam Schackart LICENSE @@ -146,19 +148,26 @@ LICENSE #ifndef INCLUDE_STB_IMAGE_WRITE_H #define INCLUDE_STB_IMAGE_WRITE_H +#ifndef STB_IMAGE_WRITE_STATIC #ifdef __cplusplus extern "C" { #endif +#endif +#ifndef STBIWDEF #ifdef STB_IMAGE_WRITE_STATIC #define STBIWDEF static #else #define STBIWDEF extern #endif +#endif +#ifndef STB_IMAGE_WRITE_STATIC +// C++ forbids static forward declarations STBIWDEF int stbi_write_tga_with_rle; STBIWDEF int stbi_write_png_compression_level; STBIWDEF int stbi_write_force_png_filter; +#endif #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes); @@ -178,9 +187,11 @@ STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean); +#ifndef STB_IMAGE_WRITE_STATIC #ifdef __cplusplus } #endif +#endif #endif//INCLUDE_STB_IMAGE_WRITE_H @@ -1480,8 +1491,8 @@ STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const #endif // STB_IMAGE_WRITE_IMPLEMENTATION /* Revision history - 1.09 (2018-xx-xx) - fix typo in zlib quality API + 1.09 (2018-02-11) + fix typo in zlib quality API, improve STB_I_W_STATIC in C++ 1.08 (2018-01-29) add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter 1.07 (2017-07-24) diff --git a/tests/test_cpp_compilation.cpp b/tests/test_cpp_compilation.cpp index 138948b..96ecf9d 100644 --- a/tests/test_cpp_compilation.cpp +++ b/tests/test_cpp_compilation.cpp @@ -2,9 +2,11 @@ #define STB_SPRINTF_IMPLEMENTATION #include "stb_sprintf.h" +#define STB_IMAGE_WRITE_STATIC + +#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_TRUETYPE_IMPLEMENTATION #define STB_PERLIN_IMPLEMENTATION -#define STB_IMAGE_WRITE_IMPLEMENTATION #define STB_DXT_IMPLEMENATION #define STB_C_LEXER_IMPLEMENTATIOn #define STB_DIVIDE_IMPLEMENTATION