Commit Graph

990 Commits

Author SHA1 Message Date
Daniel Gibson 87a0396922 stb_image.h: 16 bit TGAs don't really have an alpha channel
I claimed that if the most significant bit of a 16bit pixel is set,
it should be opaque (as is suggested by some sources on the internet),
but implemented the opposite.
If implemented "correctly", lots of 16bit TGAs become invisible.. so I
guess 16bit TGAs aren't really supposed to have an alpha-channel, or at
least most 16bit TGAs (despite having set an "alpha-bit" in the "image
descriptor byte") in the wild don't seem to work like that.

So just assume 16bit non-greyscale TGAs are always STBI_rgb without
an alpha channel.
2015-12-06 05:47:47 +01:00
Daniel Gibson d235049322 stb_image.h: Fix TGA colormap support
* Calculate correct stb format (incl. proper 16bit support) also when
  using a colormap (palette)
* Create colormap with tga_comp, to correctly support 16bit RGB
  (instead of using tga_palette_bits/8 and just copying the data)
* For TGAs with colormap, the TGA bits per pixel field specifies the
  size of an index to the colormap - the "real" color depth
  of the image is saved in the color map specification's bits per pixel
  field. I think only 8 and 16bit indices make sense (16 should be
  supported, otherwise the colormap length could be u8 instead of u16),
  so I added support for both.
* Helper functions stbi__tga_get_comp() to calculate stb pixelformat and
  stbi__tga_read_rgb16() to read one 16bit pixel and convert it to
  24/32bit RGB(A) - for less duplicate code
2015-12-06 04:33:37 +01:00
Daniel Gibson 57409c3d15 stb_image.h: Improve stbi__tga_info() and stbi__tga_test()
* for paletted images, .._info()'s comp should be based on the palette's
  bits per pixel, not the images bits per pixel (which describes the
  size of an index into the palette and is also checked now)
* make sure the color (map) type and the image type fields of the header
  are consistent (=> if TGA color type is 1 for paletted, the TGA image
  type must be 1 or 9)
* .._test() does some more checks and uses stbi__get16le() instead of
  stbi__get16be() - TGA is little endian.
* .._test() now always rewinds (sometimes it used to do only return 0;
  without rewinding)
* remove "error check" at the beginning of stbi__tga_load(), because
  all that is already tested in stbi__tga_test()
2015-12-06 04:33:30 +01:00
Daniel Gibson 7453e1bfa4 stb_image.h: Support 15/16bit per pixel RGB(A) TGAs
stbi__tga_* assumed that 16bit TGAs were Grayscale + Alpha.
However, if the TGA imagetype is not one of the gray ones, it's 16Bit
RGB data, with 5 Bits per channel. If the TGA image descriptor field
has alpha bits (the 3 least significant ones) set, the pixel's most
significant bit is for alpha: 1 for opaque and 0 for translucent.
Furthermore people claim that TGAs can also pretend to have 15bpp,
which is the same as 16bpp but definitely without alpha.

So 15/16bpp TGAs are now decoded to STBI_rgb(_alpha).
2015-12-06 00:25:22 +01:00
blackpawn a4ab8c08eb Corrected fix for stb_insertn
On insert the memmove length wasn't incorrect but the addlen call was.
2015-12-02 23:12:12 -06:00
blackpawn 28f1b0f569 Fix for stb_arr_insert 2015-12-02 22:34:04 -06:00
blackpawn cbfa0c4418 Fix stb_arr_insertn and stb_arr_deleten memmove lengths
They were moving memory beyond the array bounds.
2015-12-02 01:16:29 -06:00
Sean Barrett 64fa9a3d95 Update other_libs.md 2015-11-30 01:01:42 -08:00
Sean Barrett 2161d1e12a Update other_libs.md 2015-11-30 01:01:28 -08:00
Sean Barrett 657eda2155 Update other_libs.md 2015-11-21 03:29:15 -08:00
Sean Barrett 63849198b9 Update other_libs.md 2015-11-21 03:22:21 -08:00
baldurk 4337345c5d Prevent HDR info function from trashing stbi context by over-reading 2015-11-14 13:14:26 +01:00
Sean Barrett 5809508de3 Update other_libs.md 2015-11-12 06:12:24 -08:00
Sean Barrett 4e691f5917 Update other_libs.md 2015-11-12 06:12:06 -08:00
Sean Barrett 2b57ea95da fixed version of removed support for CODEBOOK_SHORTS 2015-11-08 19:16:25 -08:00
Sean Barrett fe74a8c223 broken attempt at removign STB_VORBIS_CODEBOOK_FLOAT option 2015-11-08 19:13:32 -08:00
Sean Barrett bc2219e1b3 fix multiple crashes on invalid files 2015-11-08 16:22:07 -08:00
Sean Barrett bdac1d2ab4 fix two crashes in invalid files 2015-11-08 16:01:40 -08:00
Sean Barrett 70b33e99f0 fix crash from invalid file 2015-11-08 14:04:56 -08:00
Sean Barrett ea88e59b5d fix invalid handling of truncated end-of-file indicator 2015-11-08 13:45:33 -08:00
Sean Barrett 69a318bdb3 fix two invalid-file crashes found by fuzz testing 2015-11-08 13:20:55 -08:00
Sean Barrett 2073403a5f fix two setup crashes found by fuzz testing 2015-11-08 13:09:30 -08:00
Sean Barrett 297ff62859 change bmp info to use common header parser 2015-11-08 13:09:16 -08:00
Sean Barrett 876aea3dbe refactor bmp header parser for sharing with stbi_info 2015-11-08 01:22:30 -08:00
Sean Barrett 16fc63404d suppress bogus static analysis warning 2015-11-08 01:03:37 -08:00
Sean Barrett 6382e49063 don't crash if out of memory allocating a new active edge (assert in debug) 2015-11-08 00:54:49 -08:00
Sean Barrett 0615df6c9b allows comments in pgm/ppm headers 2015-11-08 00:45:17 -08:00
Sean Barrett a0f850421d Merge branch 'master' into working 2015-11-08 00:41:01 -08:00
Sean Barrett 31eff2dcaf fix bug in integer parsing 2015-11-08 00:37:52 -08:00
svdijk 9f1a587d22 stb_image.h: Fix/add some comments. 2015-11-05 23:34:44 +01:00
svdijk 8603c6e809 stb_image.h: Only define stbi__l2h_{gamme,scale} when needed.
This fixes a (well, actually the only) compiler warning.
2015-11-05 23:32:40 +01:00
Sean Barrett 3f73dfd7ce Update other_libs.md 2015-11-05 06:49:02 -08:00
Sean Barrett fa9a6e4e0a Update other_libs.md 2015-11-05 06:48:42 -08:00
Sean Barrett d4cea6123a Update other_libs.md 2015-11-05 05:13:00 -08:00
Sean Barrett 20eea21e01 Update other_libs.md 2015-11-05 05:11:34 -08:00
Sean Barrett a44e950d9a Update other_libs.md 2015-11-05 04:58:42 -08:00
Sean Barrett b6602ab085 Update other_libs.md 2015-11-05 04:51:38 -08:00
Sean Barrett 450db24449 Update other_libs.md 2015-11-05 04:47:49 -08:00
Sean Barrett 76b8ff0051 Update other_libs.md 2015-11-05 04:47:36 -08:00
Sean Barrett 702c5bfee8 Update other_libs.md 2015-11-03 15:10:58 -08:00
Michael Sartain 8d9302ab05 readdir_raw buffer overrun fixes.
- Add stb_vsnprintf, stb_snprintf functions.
- stb snprintf routines should return -1 on buffer truncation on all platforms.
- Add stb_strscpy string copy function which should behave the same as Linux kernel strscpy.
- Bump readdir_raw buffer sizes up to 4k, add checks for path truncations.
- Use d_type to check for directory instead of opendir/closedir. This
  should be faster and fix recursive symlnk death.
2015-11-01 17:53:35 -08:00
Michael Sartain ba40683515 readdir_raw was skipping all dirnames starting with dots. Only skip . and .. 2015-11-01 17:53:35 -08:00
Sean Barrett 06ae60645e Update other_libs.md 2015-10-31 11:17:02 -07: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
Sean Barrett 385927fb4b Update other_libs.md 2015-10-15 17:59:40 -07:00
Rohit Nirmal 35fcd0817f stb_vorbis.c: Silence -pedantic warning. 2015-10-09 20:46:59 -05:00
Sean Barrett c4082cfb89 Update other_libs.md 2015-10-09 15:31:50 -07:00