Commit Graph

89 Commits

Author SHA1 Message Date
Sean Barrett
4eef034d52 stb_write_image: fix typos 2018-02-11 11:05:20 -08:00
Sean Barrett
445473bdb5 stb_image_write: handle malloc failure in zlib 2018-01-29 08:03:56 -08:00
Sean Barrett
b969dc38f3 stb_image_write: fix for fopen_s failure case 2018-01-29 06:06:29 -08:00
Sean Barrett
094cb31ec8 stb_image: compile as C; stb_image_write: credits 2018-01-29 04:03:18 -08:00
Sean Barrett
faf08e0018 Merge branch 'stb_image_write_mscrt_errors' of https://github.com/xeekworx/stb 2018-01-29 04:01:29 -08:00
Sean Barrett
3d7b4251f9 Merge branch 'png-ext-write' of https://github.com/akx/stb
Conflicts:
	stb_image_write.h
2018-01-29 03:14:31 -08:00
Sean Barrett
b48101c971 Merge branch 'update_stbi_jpg_dcoumentation' of https://github.com/Benjins/stb 2018-01-29 02:57:46 -08:00
Sean Barrett
35a3bf41e8 Integrate ZLIB changed from Daniel Gibson, fixup credits 2018-01-29 02:55:56 -08:00
Sean Barrett
9de22e5a70 Merge branch 'stbiw-png-compr' of https://github.com/DanielGibson/stb 2018-01-29 02:53:25 -08:00
Sean Barrett
b056850ea9 stb_image_write can flip images vertically 2018-01-29 02:52:49 -08:00
John Tullos
841862a622 Fixed grammar, spelling issues in comments
issue #533
2018-01-01 18:59:06 -06:00
John Tullos
32a7d5ab68 Added STBI_MSC_SECURE_CRT to support newer MSVC compilers as optional
For issue #533
2018-01-01 18:54:26 -06:00
John Tullos
5e844ffe70 Using secure versions of CRT calls to avoid Microsoft Visual C/C++ compiler errors/warnings. 2018-01-01 18:08:30 -06:00
Aarni Koskela
2c7b00ac21 Add force_filter and compression_level parameters to (new) stbi_write_png_to_mem_ex
* `force_filter` being < 0 means the original behavior (i.e. figure out
  the best-performing filter per scanline); any other values 0 <= x <= 4 correspond
  to PNG filters (0 = none, 1 = sub, 2 = up, 3 = average, 4 = Paeth).
* `compression_level` being < 0 equals `compression_level` 8 (the previous value).
  The higher this is, the better the compression should be (though it will use
  more memory).

These new parameters are not (yet) exposed for the higher-level API functions.
2017-08-07 14:52:53 +03:00
Benji Smith
923c9c3deb Correct function signature in stbi_write_jpg usage documentation. 2017-07-31 22:22:56 -07:00
Sean Barrett
961923b5a3 fix documentation 2017-07-24 03:32:20 -07:00
Sean Barrett
555efbedfc Update version numbers 2017-07-23 14:09:39 -07:00
Fabian Giesen
931662ae6e stb_image_write: Warning fix. 2017-07-22 16:04:07 -07:00
Daniel Gibson
be21113512 stb_image_write.h: Allow setting custom zlib compress function for PNG
The builtin stbi_zlib_compress does not compress as well as zlib or
miniz (which is not too surprising as it's <200 LOC), thus PNGs created
by stb_image_write are about 20-50% bigger than PNGs compressed with
libpng.
This change lets the user supply a custom deflate/zlib-style compress
function, which improves compression a lot. This was requested in #113.

Example for zlib:

#include <zlib.h>
unsigned char* compress_for_stbiw(unsigned char *data, int data_len,
                                  int *out_len, int quality)
{
  uLongf bufSize = compressBound(data_len);
  // note that buf will be free'd by stb_image_write.h
  // with STBIW_FREE() (plain free() by default)
  unsigned char* buf = malloc(bufSize);
  if(buf == NULL)  return NULL;
  if(compress2(buf, &bufSize, data, data_len, quality) != Z_OK)
  {
    free(buf);
    return NULL;
  }
  *out_len = bufSize;

  return buf;
}
#define STBIW_ZLIB_COMPRESS compress_for_stbiw
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
// ...
2017-07-04 19:34:31 +02:00
Daniel Gibson
e6bbecd3a9 stb_image_write.h: Set PNG compress lvl via stbi_write_png_level
This allows the user to change the deflate/zlib compress level used for
PNG compression by changing a global variable.
2017-07-04 18:07:33 +02:00
Daniel Gibson
f0baa0c287 stb_image_write.h: Fix compilation in C++11 mode
clang says:
error: non-constant-expression cannot be narrowed from type 'int'
      to 'unsigned char' in initializer list [-Wc++11-narrowing]

so I explicitly cast affected stuff to unsigned char.
2017-07-04 16:55:50 +02:00
Daniel Gibson
e5144a3996 stb_image_write.h: Consistently use STBIWDEF for stbi_write_*
Some functions were missing that in the definition, others weren't,
all had it in the declarations.

Added mention of JPG and HDR formats at the top of the file
2017-03-11 18:59:44 +01:00
Daniel Gibson
721c788fdb stb_image_write: JPEG writer based on jo_jpeg.cpp
jo_jpeg.cpp is a Public Domain JPEG writer written by Jon Olick in 2012
http://www.jonolick.com/code.html

My changes to jo_jpeg:
* port to plain C89 (+ // comments, as supported by MSVC6)
* support for 2 comp input (Greyscale+Alpha, Alpha is ignored)
* use stbi__write_context abstraction instead of stdio for writing
* adjust names to stbiw-style
2017-03-11 18:59:44 +01:00
Sean Barrett
47685c5f84 remove deprecated old-precision jpg path from stb_image.h
tweak license reference wording
2017-03-03 08:19:09 -08:00
Sean Barrett
51a5368dee Merge branch 'master' of https://github.com/pboettch/stb into working 2017-03-03 08:02:39 -08:00
Sean Barrett
96620a3a54 update version numbers 2017-01-16 00:51:24 -08:00
Sean Barrett
48710234f2 credits; 1/2/4-bit png fix; easy font spacing; NO_STDIO in image_write 2017-01-15 23:57:53 -08:00
PopPoLoPoPpo
19d03764b5 Fix #ifndef STBI_WRITE_NO_STDIO scioe for stbi_write_hdr()
stbi_write_hdr_to_func() should still be available even without STBI_WRITE_NO_STDIO,
just like other formats.
2017-01-03 02:45:16 +01:00
Patrick Boettcher
734576e6be image-write: fix monochrome bitmap writing from 8-bit-buffers
Now writing out monochrome bitmaps from 8-bit arrays works
as it does when using PNG.

Bitmaps need 3 bytes per pixel.
2016-06-15 10:36:39 +02:00
Sean Barrett
6e4154737c update version numbers, documentation, and contributors 2016-04-02 04:51:26 -07:00
Sean Barrett
097a70ae38 Merge branch 'master' of https://github.com/tulrich/stb 2016-04-02 02:56:39 -07:00
Thatcher Ulrich
291ad22e84 Replace large stack allocations with dynamic allocations. 2016-03-02 15:31:07 -05:00
Craig Donner
ee6978cb68 Slightly modify the public domain license to keep it in the public domain, but make it clear that even when dedications might not be recognized that the code is still usable. Given that this isn't dual-licensing under a different license, I'm hoping this will be acceptable. 2016-02-25 12:55:44 -08:00
Sean Barrett
f1d2002a1d update contributor list 2016-01-16 10:16:23 -08:00
Sean Barrett
58484eb73d Merge branch 'implicit_cast_fix' of https://github.com/filipwasil/stb into working 2016-01-16 10:11:54 -08:00
Sean Barrett
9f081b62a4 Merge branch 'stbiw_documentation_typo' of https://github.com/karjonas/stb into working 2016-01-16 10:11:00 -08:00
Sean Barrett
099cd5a279 Merge branch 'msvc_runtime_cast_fixes' of https://github.com/karjonas/stb into working 2016-01-16 10:10:07 -08:00
Sean Barrett
8521c38956 tweak previous crc commit 2016-01-16 10:09:35 -08:00
Sean Barrett
89aaa77b5f Merge branch 'image_write_parallel' of https://github.com/karjonas/stb into working 2016-01-16 10:04:45 -08:00
Sean Barrett
20aca08f86 Merge branch 'master' of https://github.com/zerhacken/stb into working 2016-01-16 10:02:56 -08:00
Sean Barrett
b9216ddb36 Merge branch 'master' of https://github.com/serge-rgb/stb into working
Conflicts:
	stb_image_write.h
2016-01-16 10:02:30 -08:00
Sean Barrett
ac748cba9b update contributor list, version history, version number 2016-01-16 09:57:04 -08:00
Sean Barrett
82ca643ef3 change previous explicitly-sized realloc support to be new API and unbreak old API 2016-01-16 09:47:22 -08:00
Romain Bailly
7e741ffc1e Added the old size as argument to the STBI_REALLOC() and STBIW_REALLOC() macros 2016-01-14 10:34:30 +01:00
Filip Wasil
8cea0090b2 Removie implicit cast to float
When compiling with more restrictive compiler options
such casting from double to float will cause a warning.

Ex. GCC -Wdouble-promotion

Signed-off-by: Filip Wasil <filip.wasil@gmail.com>
2015-10-29 16:09:21 +01:00
Jonas Karlsson
b95858a2f7 Add bitmask to unsigned char casts to fix MSVC runtime checks 2015-10-20 23:22:27 +02:00
Jonas Karlsson
22dd50f256 Fix documentation error 2015-10-20 22:03:50 +02:00
Jonas Karlsson
f1d401845f Fix race condition in static crc_table
If calling stbi_write_png concurrently the static array crc_table would be shared between threads causing data-races.
2015-10-17 17:33:00 +02:00
Rasmus Christian Pedersen
007c850b48 nobug: removed unused variable 'k' 2015-09-25 19:46:27 +02:00
Sergio Gonzalez
b372a1f86c Avoid macro redefinition in Win32 2015-09-21 12:18:18 -05:00