remove deprecated old-precision jpg path from stb_image.h
tweak license reference wording
This commit is contained in:
parent
51a5368dee
commit
47685c5f84
@ -36,7 +36,7 @@
|
|||||||
//
|
//
|
||||||
// LICENSE
|
// LICENSE
|
||||||
//
|
//
|
||||||
// See end of file for licensing information.
|
// See end of file for license information.
|
||||||
|
|
||||||
#ifndef STB_C_LEXER_DEFINITIONS
|
#ifndef STB_C_LEXER_DEFINITIONS
|
||||||
// to change the default parsing rules, copy the following lines
|
// to change the default parsing rules, copy the following lines
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
//
|
//
|
||||||
// LICENSE
|
// LICENSE
|
||||||
//
|
//
|
||||||
// See end of file for licensing information.
|
// See end of file for license information.
|
||||||
//
|
//
|
||||||
// ALGORITHM
|
// ALGORITHM
|
||||||
//
|
//
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
//
|
//
|
||||||
// LICENSE
|
// LICENSE
|
||||||
//
|
//
|
||||||
// See end of file for licensing information.
|
// See end of file for license information.
|
||||||
|
|
||||||
|
|
||||||
#ifndef INCLUDE_STB_DIVIDE_H
|
#ifndef INCLUDE_STB_DIVIDE_H
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
//
|
//
|
||||||
// LICENSE
|
// LICENSE
|
||||||
//
|
//
|
||||||
// See end of file for licensing information.
|
// See end of file for license information.
|
||||||
|
|
||||||
#ifndef STB_INCLUDE_STB_DXT_H
|
#ifndef STB_INCLUDE_STB_DXT_H
|
||||||
#define STB_INCLUDE_STB_DXT_H
|
#define STB_INCLUDE_STB_DXT_H
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
//
|
//
|
||||||
// LICENSE
|
// LICENSE
|
||||||
//
|
//
|
||||||
// See end of file for licensing information.
|
// See end of file for license information.
|
||||||
//
|
//
|
||||||
// VERSION HISTORY
|
// VERSION HISTORY
|
||||||
//
|
//
|
||||||
|
206
stb_image.h
206
stb_image.h
@ -21,7 +21,7 @@
|
|||||||
avoid problematic images and only need the trivial interface
|
avoid problematic images and only need the trivial interface
|
||||||
|
|
||||||
JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
|
JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
|
||||||
PNG 1/2/4/8-bit-per-channel (16 bpc not supported)
|
PNG 1/2/4/8/16-bit-per-channel
|
||||||
|
|
||||||
TGA (not sure what subset, if a subset)
|
TGA (not sure what subset, if a subset)
|
||||||
BMP non-1bpp, non-RLE
|
BMP non-1bpp, non-RLE
|
||||||
@ -42,110 +42,13 @@
|
|||||||
Full documentation under "DOCUMENTATION" below.
|
Full documentation under "DOCUMENTATION" below.
|
||||||
|
|
||||||
|
|
||||||
Revision 2.00 release notes:
|
LICENSE
|
||||||
|
|
||||||
- Progressive JPEG is now supported.
|
See end of file for license information.
|
||||||
|
|
||||||
- PPM and PGM binary formats are now supported, thanks to Ken Miller.
|
RECENT REVISION HISTORY:
|
||||||
|
|
||||||
- x86 platforms now make use of SSE2 SIMD instructions for
|
2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD
|
||||||
JPEG decoding, and ARM platforms can use NEON SIMD if requested.
|
|
||||||
This work was done by Fabian "ryg" Giesen. SSE2 is used by
|
|
||||||
default, but NEON must be enabled explicitly; see docs.
|
|
||||||
|
|
||||||
With other JPEG optimizations included in this version, we see
|
|
||||||
2x speedup on a JPEG on an x86 machine, and a 1.5x speedup
|
|
||||||
on a JPEG on an ARM machine, relative to previous versions of this
|
|
||||||
library. The same results will not obtain for all JPGs and for all
|
|
||||||
x86/ARM machines. (Note that progressive JPEGs are significantly
|
|
||||||
slower to decode than regular JPEGs.) This doesn't mean that this
|
|
||||||
is the fastest JPEG decoder in the land; rather, it brings it
|
|
||||||
closer to parity with standard libraries. If you want the fastest
|
|
||||||
decode, look elsewhere. (See "Philosophy" section of docs below.)
|
|
||||||
|
|
||||||
See final bullet items below for more info on SIMD.
|
|
||||||
|
|
||||||
- Added STBI_MALLOC, STBI_REALLOC, and STBI_FREE macros for replacing
|
|
||||||
the memory allocator. Unlike other STBI libraries, these macros don't
|
|
||||||
support a context parameter, so if you need to pass a context in to
|
|
||||||
the allocator, you'll have to store it in a global or a thread-local
|
|
||||||
variable.
|
|
||||||
|
|
||||||
- Split existing STBI_NO_HDR flag into two flags, STBI_NO_HDR and
|
|
||||||
STBI_NO_LINEAR.
|
|
||||||
STBI_NO_HDR: suppress implementation of .hdr reader format
|
|
||||||
STBI_NO_LINEAR: suppress high-dynamic-range light-linear float API
|
|
||||||
|
|
||||||
- You can suppress implementation of any of the decoders to reduce
|
|
||||||
your code footprint by #defining one or more of the following
|
|
||||||
symbols before creating the implementation.
|
|
||||||
|
|
||||||
STBI_NO_JPEG
|
|
||||||
STBI_NO_PNG
|
|
||||||
STBI_NO_BMP
|
|
||||||
STBI_NO_PSD
|
|
||||||
STBI_NO_TGA
|
|
||||||
STBI_NO_GIF
|
|
||||||
STBI_NO_HDR
|
|
||||||
STBI_NO_PIC
|
|
||||||
STBI_NO_PNM (.ppm and .pgm)
|
|
||||||
|
|
||||||
- You can request *only* certain decoders and suppress all other ones
|
|
||||||
(this will be more forward-compatible, as addition of new decoders
|
|
||||||
doesn't require you to disable them explicitly):
|
|
||||||
|
|
||||||
STBI_ONLY_JPEG
|
|
||||||
STBI_ONLY_PNG
|
|
||||||
STBI_ONLY_BMP
|
|
||||||
STBI_ONLY_PSD
|
|
||||||
STBI_ONLY_TGA
|
|
||||||
STBI_ONLY_GIF
|
|
||||||
STBI_ONLY_HDR
|
|
||||||
STBI_ONLY_PIC
|
|
||||||
STBI_ONLY_PNM (.ppm and .pgm)
|
|
||||||
|
|
||||||
Note that you can define multiples of these, and you will get all
|
|
||||||
of them ("only x" and "only y" is interpreted to mean "only x&y").
|
|
||||||
|
|
||||||
- If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still
|
|
||||||
want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB
|
|
||||||
|
|
||||||
- Compilation of all SIMD code can be suppressed with
|
|
||||||
#define STBI_NO_SIMD
|
|
||||||
It should not be necessary to disable SIMD unless you have issues
|
|
||||||
compiling (e.g. using an x86 compiler which doesn't support SSE
|
|
||||||
intrinsics or that doesn't support the method used to detect
|
|
||||||
SSE2 support at run-time), and even those can be reported as
|
|
||||||
bugs so I can refine the built-in compile-time checking to be
|
|
||||||
smarter.
|
|
||||||
|
|
||||||
- The old STBI_SIMD system which allowed installing a user-defined
|
|
||||||
IDCT etc. has been removed. If you need this, don't upgrade. My
|
|
||||||
assumption is that almost nobody was doing this, and those who
|
|
||||||
were will find the built-in SIMD more satisfactory anyway.
|
|
||||||
|
|
||||||
- RGB values computed for JPEG images are slightly different from
|
|
||||||
previous versions of stb_image. (This is due to using less
|
|
||||||
integer precision in SIMD.) The C code has been adjusted so
|
|
||||||
that the same RGB values will be computed regardless of whether
|
|
||||||
SIMD support is available, so your app should always produce
|
|
||||||
consistent results. But these results are slightly different from
|
|
||||||
previous versions. (Specifically, about 3% of available YCbCr values
|
|
||||||
will compute different RGB results from pre-1.49 versions by +-1;
|
|
||||||
most of the deviating values are one smaller in the G channel.)
|
|
||||||
|
|
||||||
- If you must produce consistent results with previous versions of
|
|
||||||
stb_image, #define STBI_JPEG_OLD and you will get the same results
|
|
||||||
you used to; however, you will not get the SIMD speedups for
|
|
||||||
the YCbCr-to-RGB conversion step (although you should still see
|
|
||||||
significant JPEG speedup from the other changes).
|
|
||||||
|
|
||||||
Please note that STBI_JPEG_OLD is a temporary feature; it will be
|
|
||||||
removed in future versions of the library. It is only intended for
|
|
||||||
near-term back-compatibility use.
|
|
||||||
|
|
||||||
|
|
||||||
Latest revision history:
|
|
||||||
2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes
|
2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes
|
||||||
2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
|
2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
|
||||||
2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64
|
2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64
|
||||||
@ -194,11 +97,6 @@
|
|||||||
Philipp Wiesemann Josh Tobin github:rlyeh github:grim210@github
|
Philipp Wiesemann Josh Tobin github:rlyeh github:grim210@github
|
||||||
Blazej Dariusz Roszkowski github:sammyhw
|
Blazej Dariusz Roszkowski github:sammyhw
|
||||||
|
|
||||||
|
|
||||||
LICENSE
|
|
||||||
|
|
||||||
See end of file for licensing information.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef STBI_INCLUDE_STB_IMAGE_H
|
#ifndef STBI_INCLUDE_STB_IMAGE_H
|
||||||
@ -272,13 +170,13 @@ LICENSE
|
|||||||
// and for best performance I may provide less-easy-to-use APIs that give higher
|
// and for best performance I may provide less-easy-to-use APIs that give higher
|
||||||
// performance, in addition to the easy to use ones. Nevertheless, it's important
|
// performance, in addition to the easy to use ones. Nevertheless, it's important
|
||||||
// to keep in mind that from the standpoint of you, a client of this library,
|
// to keep in mind that from the standpoint of you, a client of this library,
|
||||||
// all you care about is #1 and #3, and stb libraries do not emphasize #3 above all.
|
// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all.
|
||||||
//
|
//
|
||||||
// Some secondary priorities arise directly from the first two, some of which
|
// Some secondary priorities arise directly from the first two, some of which
|
||||||
// make more explicit reasons why performance can't be emphasized.
|
// make more explicit reasons why performance can't be emphasized.
|
||||||
//
|
//
|
||||||
// - Portable ("ease of use")
|
// - Portable ("ease of use")
|
||||||
// - Small footprint ("easy to maintain")
|
// - Small source code footprint ("easy to maintain")
|
||||||
// - No dependencies ("ease of use")
|
// - No dependencies ("ease of use")
|
||||||
//
|
//
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
@ -310,13 +208,6 @@ LICENSE
|
|||||||
// (at least this is true for iOS and Android). Therefore, the NEON support is
|
// (at least this is true for iOS and Android). Therefore, the NEON support is
|
||||||
// toggled by a build flag: define STBI_NEON to get NEON loops.
|
// toggled by a build flag: define STBI_NEON to get NEON loops.
|
||||||
//
|
//
|
||||||
// The output of the JPEG decoder is slightly different from versions where
|
|
||||||
// SIMD support was introduced (that is, for versions before 1.49). The
|
|
||||||
// difference is only +-1 in the 8-bit RGB channels, and only on a small
|
|
||||||
// fraction of pixels. You can force the pre-1.49 behavior by defining
|
|
||||||
// STBI_JPEG_OLD, but this will disable some of the SIMD decoding path
|
|
||||||
// and hence cost some performance.
|
|
||||||
//
|
|
||||||
// If for some reason you do not want to use any of SIMD code, or if
|
// If for some reason you do not want to use any of SIMD code, or if
|
||||||
// you have issues compiling it, you can disable it entirely by
|
// you have issues compiling it, you can disable it entirely by
|
||||||
// defining STBI_NO_SIMD.
|
// defining STBI_NO_SIMD.
|
||||||
@ -372,6 +263,41 @@ LICENSE
|
|||||||
// says there's premultiplied data (currently only happens in iPhone images,
|
// says there's premultiplied data (currently only happens in iPhone images,
|
||||||
// and only if iPhone convert-to-rgb processing is on).
|
// and only if iPhone convert-to-rgb processing is on).
|
||||||
//
|
//
|
||||||
|
// ===========================================================================
|
||||||
|
//
|
||||||
|
// ADDITIONAL CONFIGURATION
|
||||||
|
//
|
||||||
|
// - You can suppress implementation of any of the decoders to reduce
|
||||||
|
// your code footprint by #defining one or more of the following
|
||||||
|
// symbols before creating the implementation.
|
||||||
|
//
|
||||||
|
// STBI_NO_JPEG
|
||||||
|
// STBI_NO_PNG
|
||||||
|
// STBI_NO_BMP
|
||||||
|
// STBI_NO_PSD
|
||||||
|
// STBI_NO_TGA
|
||||||
|
// STBI_NO_GIF
|
||||||
|
// STBI_NO_HDR
|
||||||
|
// STBI_NO_PIC
|
||||||
|
// STBI_NO_PNM (.ppm and .pgm)
|
||||||
|
//
|
||||||
|
// - You can request *only* certain decoders and suppress all other ones
|
||||||
|
// (this will be more forward-compatible, as addition of new decoders
|
||||||
|
// doesn't require you to disable them explicitly):
|
||||||
|
//
|
||||||
|
// STBI_ONLY_JPEG
|
||||||
|
// STBI_ONLY_PNG
|
||||||
|
// STBI_ONLY_BMP
|
||||||
|
// STBI_ONLY_PSD
|
||||||
|
// STBI_ONLY_TGA
|
||||||
|
// STBI_ONLY_GIF
|
||||||
|
// STBI_ONLY_HDR
|
||||||
|
// STBI_ONLY_PIC
|
||||||
|
// STBI_ONLY_PNM (.ppm and .pgm)
|
||||||
|
//
|
||||||
|
// - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still
|
||||||
|
// want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef STBI_NO_STDIO
|
#ifndef STBI_NO_STDIO
|
||||||
@ -3345,38 +3271,9 @@ static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STBI_JPEG_OLD
|
|
||||||
// this is the same YCbCr-to-RGB calculation that stb_image has used
|
|
||||||
// historically before the algorithm changes in 1.49
|
|
||||||
#define float2fixed(x) ((int) ((x) * 65536 + 0.5))
|
|
||||||
static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i=0; i < count; ++i) {
|
|
||||||
int y_fixed = (y[i] << 16) + 32768; // rounding
|
|
||||||
int r,g,b;
|
|
||||||
int cr = pcr[i] - 128;
|
|
||||||
int cb = pcb[i] - 128;
|
|
||||||
r = y_fixed + cr*float2fixed(1.40200f);
|
|
||||||
g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f);
|
|
||||||
b = y_fixed + cb*float2fixed(1.77200f);
|
|
||||||
r >>= 16;
|
|
||||||
g >>= 16;
|
|
||||||
b >>= 16;
|
|
||||||
if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
|
|
||||||
if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
|
|
||||||
if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
|
|
||||||
out[0] = (stbi_uc)r;
|
|
||||||
out[1] = (stbi_uc)g;
|
|
||||||
out[2] = (stbi_uc)b;
|
|
||||||
out[3] = 255;
|
|
||||||
out += step;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// this is a reduced-precision calculation of YCbCr-to-RGB introduced
|
// this is a reduced-precision calculation of YCbCr-to-RGB introduced
|
||||||
// to make sure the code produces the same results in both SIMD and scalar
|
// to make sure the code produces the same results in both SIMD and scalar
|
||||||
#define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8)
|
#define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8)
|
||||||
static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
|
static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -3385,9 +3282,9 @@ static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc
|
|||||||
int r,g,b;
|
int r,g,b;
|
||||||
int cr = pcr[i] - 128;
|
int cr = pcr[i] - 128;
|
||||||
int cb = pcb[i] - 128;
|
int cb = pcb[i] - 128;
|
||||||
r = y_fixed + cr* float2fixed(1.40200f);
|
r = y_fixed + cr* stbi__float2fixed(1.40200f);
|
||||||
g = y_fixed + (cr*-float2fixed(0.71414f)) + ((cb*-float2fixed(0.34414f)) & 0xffff0000);
|
g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
|
||||||
b = y_fixed + cb* float2fixed(1.77200f);
|
b = y_fixed + cb* stbi__float2fixed(1.77200f);
|
||||||
r >>= 20;
|
r >>= 20;
|
||||||
g >>= 20;
|
g >>= 20;
|
||||||
b >>= 20;
|
b >>= 20;
|
||||||
@ -3401,7 +3298,6 @@ static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc
|
|||||||
out += step;
|
out += step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(STBI_SSE2) || defined(STBI_NEON)
|
#if defined(STBI_SSE2) || defined(STBI_NEON)
|
||||||
static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step)
|
static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step)
|
||||||
@ -3520,9 +3416,9 @@ static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc cons
|
|||||||
int r,g,b;
|
int r,g,b;
|
||||||
int cr = pcr[i] - 128;
|
int cr = pcr[i] - 128;
|
||||||
int cb = pcb[i] - 128;
|
int cb = pcb[i] - 128;
|
||||||
r = y_fixed + cr* float2fixed(1.40200f);
|
r = y_fixed + cr* stbi__float2fixed(1.40200f);
|
||||||
g = y_fixed + cr*-float2fixed(0.71414f) + ((cb*-float2fixed(0.34414f)) & 0xffff0000);
|
g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
|
||||||
b = y_fixed + cb* float2fixed(1.77200f);
|
b = y_fixed + cb* stbi__float2fixed(1.77200f);
|
||||||
r >>= 20;
|
r >>= 20;
|
||||||
g >>= 20;
|
g >>= 20;
|
||||||
b >>= 20;
|
b >>= 20;
|
||||||
@ -3548,18 +3444,14 @@ static void stbi__setup_jpeg(stbi__jpeg *j)
|
|||||||
#ifdef STBI_SSE2
|
#ifdef STBI_SSE2
|
||||||
if (stbi__sse2_available()) {
|
if (stbi__sse2_available()) {
|
||||||
j->idct_block_kernel = stbi__idct_simd;
|
j->idct_block_kernel = stbi__idct_simd;
|
||||||
#ifndef STBI_JPEG_OLD
|
|
||||||
j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
|
j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
|
||||||
#endif
|
|
||||||
j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
|
j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STBI_NEON
|
#ifdef STBI_NEON
|
||||||
j->idct_block_kernel = stbi__idct_simd;
|
j->idct_block_kernel = stbi__idct_simd;
|
||||||
#ifndef STBI_JPEG_OLD
|
|
||||||
j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
|
j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
|
||||||
#endif
|
|
||||||
j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
|
j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* stb_image_write - v1.03 - public domain - http://nothings.org/stb/stb_image_write.h
|
/* stb_image_write - v1.05 - public domain - http://nothings.org/stb/stb_image_write.h
|
||||||
writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010-2015
|
writes out PNG/BMP/TGA images to C stdio - Sean Barrett 2010-2015
|
||||||
no warranty implied; use at your own risk
|
no warranty implied; use at your own risk
|
||||||
|
|
||||||
@ -104,12 +104,11 @@ CREDITS:
|
|||||||
Filip Wasil
|
Filip Wasil
|
||||||
Thatcher Ulrich
|
Thatcher Ulrich
|
||||||
github:poppolopoppo
|
github:poppolopoppo
|
||||||
|
Patrick Boettcher
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
This software is dual-licensed to the public domain and under the following
|
See end of file for license information.
|
||||||
license: you are granted a perpetual, irrevocable license to copy, modify,
|
|
||||||
publish, and distribute this file as you see fit.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -294,8 +293,8 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in
|
|||||||
s->func(s->context, &d[comp - 1], 1);
|
s->func(s->context, &d[comp - 1], 1);
|
||||||
|
|
||||||
switch (comp) {
|
switch (comp) {
|
||||||
case 1: /* fall-through wanted */
|
case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case
|
||||||
case 2:
|
case 1:
|
||||||
if (expand_mono)
|
if (expand_mono)
|
||||||
stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
|
stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
|
||||||
else
|
else
|
||||||
@ -895,6 +894,7 @@ static unsigned char stbiw__paeth(int a, int b, int c)
|
|||||||
return STBIW_UCHAR(c);
|
return STBIW_UCHAR(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @OPTIMIZE: provide an option that always forces left-predict or paeth predict
|
||||||
unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
|
unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
|
||||||
{
|
{
|
||||||
int ctype[5] = { -1, 0, 4, 2, 6 };
|
int ctype[5] = { -1, 0, 4, 2, 6 };
|
||||||
@ -911,10 +911,10 @@ unsigned char *stbi_write_png_to_mem(unsigned char *pixels, int stride_bytes, in
|
|||||||
for (j=0; j < y; ++j) {
|
for (j=0; j < y; ++j) {
|
||||||
static int mapping[] = { 0,1,2,3,4 };
|
static int mapping[] = { 0,1,2,3,4 };
|
||||||
static int firstmap[] = { 0,1,0,5,6 };
|
static int firstmap[] = { 0,1,0,5,6 };
|
||||||
int *mymap = j ? mapping : firstmap;
|
int *mymap = (j != 0) ? mapping : firstmap;
|
||||||
int best = 0, bestval = 0x7fffffff;
|
int best = 0, bestval = 0x7fffffff;
|
||||||
for (p=0; p < 2; ++p) {
|
for (p=0; p < 2; ++p) {
|
||||||
for (k= p?best:0; k < 5; ++k) {
|
for (k= p?best:0; k < 5; ++k) { // @TODO: clarity: rewrite this to go 0..5, and 'continue' the unwanted ones during 2nd pass
|
||||||
int type = mymap[k],est=0;
|
int type = mymap[k],est=0;
|
||||||
unsigned char *z = pixels + stride_bytes*j;
|
unsigned char *z = pixels + stride_bytes*j;
|
||||||
for (i=0; i < n; ++i)
|
for (i=0; i < n; ++i)
|
||||||
@ -1016,6 +1016,9 @@ STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x,
|
|||||||
#endif // STB_IMAGE_WRITE_IMPLEMENTATION
|
#endif // STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
|
||||||
/* Revision history
|
/* Revision history
|
||||||
|
1.04 (2017-03-03)
|
||||||
|
monochrome BMP expansion
|
||||||
|
1.03 ???
|
||||||
1.02 (2016-04-02)
|
1.02 (2016-04-02)
|
||||||
avoid allocating large structures on the stack
|
avoid allocating large structures on the stack
|
||||||
1.01 (2016-01-16)
|
1.01 (2016-01-16)
|
||||||
@ -1045,3 +1048,45 @@ STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x,
|
|||||||
first public release
|
first public release
|
||||||
0.90 first internal release
|
0.90 first internal release
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
This software is available under 2 licenses -- choose whichever you prefer.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
ALTERNATIVE A - MIT License
|
||||||
|
Copyright (c) 2017 Sean Barrett
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||||
|
software, either in source code form or as a compiled binary, for any purpose,
|
||||||
|
commercial or non-commercial, and by any means.
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||||
|
software dedicate any and all copyright interest in the software to the public
|
||||||
|
domain. We make this dedication for the benefit of the public at large and to
|
||||||
|
the detriment of our heirs and successors. We intend this dedication to be an
|
||||||
|
overt act of relinquishment in perpetuity of all present and future rights to
|
||||||
|
this software under copyright law.
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user