Commit Graph

429 Commits

Author SHA1 Message Date
Sean Barrett 08e4b18650 Merge branch 'dev' of https://github.com/nothings/stb into dev 2021-07-07 00:39:10 -07:00
Fabian Giesen 6ca560c9af stb_image: Update documentation for de-iPhone flag
It's default off, not default on.

Fixes issue #651.
2021-07-06 21:40:31 -07:00
Fabian Giesen 7e10880f53 stb_image: Update credits 2021-07-06 20:47:30 -07:00
Vladimír Vondruš 2c8cd33e2e stb_image: make unpremultiply and de-iPhone flags thread_local.
Follows the change done for vertical flipping in
eb48fbdced for these two options as well.
2021-07-06 20:46:41 -07:00
Fabian Giesen 1e82fd4a4e stb_image: BMP v4/v5 header parsing fixes
As per MS's own docs, should ignore the r/g/b bitmasks in the
header unless BI_BITFIELDS compression is selected. Factor out
setting the default masks since that now exists in two branches.

Add some more checking for unsupported compression formats and
illegal bpp/compression combinations while I'm at it.

Fixes issue #783.
2021-07-04 22:17:57 -07:00
Fabian Giesen 17bc84e15d stb_image: stbi__bmp_info only rewind stream on error
To be consistent with the other info functions.

Fixes issue #892.
2021-07-04 21:47:13 -07:00
Fabian Giesen ab18d9b250 stb_image: Fix two bugs found via VC++ /analyze
Also fixes issue #366.
2021-07-04 21:42:44 -07:00
Fabian Giesen 82f9950cea stb_image: Update credits 2021-07-04 01:39:10 -07:00
Eugene Golushkov db864a1e30 stb_image: fix building by MSVC for Windows 10 on ARM 2021-07-04 01:39:10 -07:00
Fabian Giesen 2506215e8a stb_image: Key Win32 UTF-8 support off _WIN32 not _MSC_VER
So that it also works on MinGW.

Fixes issue #729.
2021-07-04 01:39:10 -07:00
Fabian Giesen 991f1f6419 stb_image: Fix wrong buffer sizes passed to MultiByteToWideChar
Fixes issue #772.
2021-07-04 01:39:10 -07:00
Fabian Giesen 56a7113cd0 stb_image: Reorder format test sequence
Put the formats that start with a clear magic number first,
the dodgy ones that don't have much of a distinctive header
should be tested for later after we've ruled out the clearer
ones.

Fixes issue #787, hopefully. (Never got a clean repro.)
2021-07-04 01:39:10 -07:00
Fabian Giesen 618dbd01c8 stb_image: Document image size limits
Both the buffer size limits and the image dimension limits.

Fixes issue #672.
2021-07-04 01:39:10 -07:00
Fabian Giesen 4d3b93f589 stb_image: Erorr in BMP should error, not assert.
There was both the assert and the error check; should just be
the error check.

Fixes issue #881 (or rather, part of it).
2021-07-04 01:39:09 -07:00
Fabian Giesen 31ba943e3f stb_image: UB fix in stbi__get32le
Need to do the second-part shift on uint32 not int.
2021-07-04 01:39:09 -07:00
Fabian Giesen d6ab7faec0 stb_image: Update comment
As per recent patches, we do support 16-bit PNMs.
2021-07-04 01:39:09 -07:00
Fabian Giesen bb09317445 stb_image: Avoid left-shifts of signed values
It's implementation-specified behavior. Writing this code and then
relying on compiler strength reduction to turn it back into shifts
feels extremely silly but it is what it is.

Fixes issue #1097.
2021-07-04 01:39:09 -07:00
Fabian Giesen 43b32c7bab stb_image: Avoid shift of signed values in extend_receive
Use an equivalent formulation that has sgn=0 or 1, not 0 or -1.
This avoids right-shifting signed values, at least in this place.

Fixes issue #1061.
2021-07-04 01:39:09 -07:00
Fabian Giesen 6d857933d5 stb_image, stb_image_write: Fix compare sign warnings
For the stb_image fix, also replace the magic 288 with a more
descriptive name while I'm at it.

Fixes #1100
2021-07-04 01:39:09 -07:00
Fabian Giesen 265b73bb0b stb_image: Fix lrot definition, small extend_receive tweak
Define lrot in a way that doesn't involve UB when n==0.
Also, the previous patch ensures that n <= 15 for all callers
of stbi__extend_receive, so can remove the (less restrictive)
bounds check for 0 <= n < 17 (the bounds of stbi__bmask)
entirely.

Fixes issue #1065.
2021-07-04 01:39:09 -07:00
Fabian Giesen 86b7570cfb stb_image: Fix bug on JPEGs with malformed DC deltas
extend_receive implicitly requires n <= 15 (code length);
the maximum that actually makes sense for 8-bit baseline JPEG is
11, but 15 is the natural limit for us because the AC coding path
stores the number of magnitude bits in a nibble.

Check that DC delta bits are in range before attempting to call
extend_receive.

Fixes issue #1108.
2021-07-04 01:39:09 -07:00
Fabian Giesen 6ab6303f98 stb_image: Check results of all mallocs.
A few were missing. Make sure to always report ouf-of-memory
errors.

Fixes issue #1056.
2021-07-04 01:39:09 -07:00
Fabian Giesen 8e8f7d9b69 stb_image: Update credits, change log 2021-07-04 01:38:24 -07:00
Simon Breuss 8c15cc9c79 Adds 16-bit support for pnm files. 2021-07-04 01:38:24 -07:00
Jacko Dirks c62af85657 stb_image.h: Suppress warnings about out_size, delay_size
These two variables are unused on some targets, resulting in
warnings. Add STBI_NOTUSED around them to suppress those
warnings.
2021-07-04 01:38:24 -07:00
Fabian Giesen 448bb137e3 stb_image: Better docs for stbi_info.
Fixes #1026.
2021-07-04 01:38:24 -07:00
Fabian Giesen 1203eb554b stb_image: Fix issue #994.
Accidentally introduced during a merge.
2021-07-04 01:38:24 -07:00
Fabian Giesen 5c0cc31fb0 stb_image: Update credits 2021-07-03 01:00:46 -07:00
Eugene Golushkov 69a7dd32a8 stb_image: fix building by MSVC for Windows 10 on ARM 2021-07-03 00:59:26 -07:00
Fabian Giesen a0231a9e94 stb_image: Key Win32 UTF-8 support off _WIN32 not _MSC_VER
So that it also works on MinGW.

Fixes issue #729.
2021-07-03 00:46:04 -07:00
Fabian Giesen e3a63f3793 stb_image: Fix wrong buffer sizes passed to MultiByteToWideChar
Fixes issue #772.
2021-07-03 00:38:30 -07:00
Fabian Giesen 3870fb6a93 stb_image: Reorder format test sequence
Put the formats that start with a clear magic number first,
the dodgy ones that don't have much of a distinctive header
should be tested for later after we've ruled out the clearer
ones.

Fixes issue #787, hopefully. (Never got a clean repro.)
2021-07-02 23:06:44 -07:00
Fabian Giesen e795306bbc stb_image: Document image size limits
Both the buffer size limits and the image dimension limits.

Fixes issue #672.
2021-07-02 22:52:15 -07:00
Fabian Giesen d343a29fe6 stb_image: Erorr in BMP should error, not assert.
There was both the assert and the error check; should just be
the error check.

Fixes issue #881 (or rather, part of it).
2021-07-02 22:01:23 -07:00
Fabian Giesen 41e93836d9 stb_image: UB fix in stbi__get32le
Need to do the second-part shift on uint32 not int.
2021-07-02 21:57:25 -07:00
Fabian Giesen cf00c67c57 stb_image: Update comment
As per recent patches, we do support 16-bit PNMs.
2021-07-02 21:38:44 -07:00
Fabian Giesen 48632c1752 stb_image: Avoid left-shifts of signed values
It's implementation-specified behavior. Writing this code and then
relying on compiler strength reduction to turn it back into shifts
feels extremely silly but it is what it is.

Fixes issue #1097.
2021-07-02 21:09:11 -07:00
Fabian Giesen 026013546c stb_image: Avoid shift of signed values in extend_receive
Use an equivalent formulation that has sgn=0 or 1, not 0 or -1.
This avoids right-shifting signed values, at least in this place.

Fixes issue #1061.
2021-07-02 20:59:22 -07:00
Fabian Giesen 4d067e8b2b stb_image, stb_image_write: Fix compare sign warnings
For the stb_image fix, also replace the magic 288 with a more
descriptive name while I'm at it.

Fixes #1100
2021-07-02 18:42:01 -07:00
Fabian Giesen 1d7bf85877 stb_image: Fix lrot definition, small extend_receive tweak
Define lrot in a way that doesn't involve UB when n==0.
Also, the previous patch ensures that n <= 15 for all callers
of stbi__extend_receive, so can remove the (less restrictive)
bounds check for 0 <= n < 17 (the bounds of stbi__bmask)
entirely.

Fixes issue #1065.
2021-07-02 18:28:41 -07:00
Fabian Giesen a3f2897b85 stb_image: Fix bug on JPEGs with malformed DC deltas
extend_receive implicitly requires n <= 15 (code length);
the maximum that actually makes sense for 8-bit baseline JPEG is
11, but 15 is the natural limit for us because the AC coding path
stores the number of magnitude bits in a nibble.

Check that DC delta bits are in range before attempting to call
extend_receive.

Fixes issue #1108.
2021-07-02 18:10:49 -07:00
Fabian Giesen 50072f6658 stb_image: Check results of all mallocs.
A few were missing. Make sure to always report ouf-of-memory
errors.

Fixes issue #1056.
2021-07-02 17:52:29 -07:00
Fabian Giesen b4891baa6c stb_image: Update credits, change log 2021-07-01 17:35:40 -07:00
Simon Breuss 8befa752b0 Adds 16-bit support for pnm files. 2021-07-01 17:33:58 -07:00
Jacko Dirks 655b2b1f06 stb_image.h: Suppress warnings about out_size, delay_size
These two variables are unused on some targets, resulting in
warnings. Add STBI_NOTUSED around them to suppress those
warnings.
2021-07-01 17:24:12 -07:00
Fabian Giesen 3a7dcdd269 stb_image: Better docs for stbi_info.
Fixes #1026.
2021-07-01 17:18:51 -07:00
Fabian Giesen bc4e96b5a7 stb_image: Fix issue #994.
Accidentally introduced during a merge.
2021-07-01 17:11:25 -07:00
Sean Barrett e140649ccf remove trailign whitespace 2020-07-13 04:40:31 -07:00
Sean Barrett 314d0a6f9a update version numbers 2020-07-13 04:36:03 -07:00
Sean Barrett f3085776a4 Merge branch 'patch-1' of https://github.com/coltongit/stb into working 2020-07-13 04:07:16 -07:00