mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-02-03 09:44:26 -05:00
Updated LodePNG to 2016.11.27 version (indeed current master)
This commit is contained in:
parent
946a9801dc
commit
1e14eece65
24
external/lodepng/lodepng.cpp
vendored
24
external/lodepng/lodepng.cpp
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
LodePNG version 20160501
|
LodePNG version 20161127
|
||||||
|
|
||||||
Copyright (c) 2005-2016 Lode Vandevenne
|
Copyright (c) 2005-2016 Lode Vandevenne
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for
|
|||||||
#pragma warning( disable : 4996 ) /*VS does not like fopen, but fopen_s is not standard C so unusable here*/
|
#pragma warning( disable : 4996 ) /*VS does not like fopen, but fopen_s is not standard C so unusable here*/
|
||||||
#endif /*_MSC_VER */
|
#endif /*_MSC_VER */
|
||||||
|
|
||||||
const char* LODEPNG_VERSION_STRING = "20160501";
|
const char* LODEPNG_VERSION_STRING = "20161127";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This source file is built up in the following large parts. The code sections
|
This source file is built up in the following large parts. The code sections
|
||||||
@ -3534,8 +3534,8 @@ void lodepng_color_profile_init(LodePNGColorProfile* profile)
|
|||||||
{
|
{
|
||||||
profile->colored = 0;
|
profile->colored = 0;
|
||||||
profile->key = 0;
|
profile->key = 0;
|
||||||
profile->alpha = 0;
|
|
||||||
profile->key_r = profile->key_g = profile->key_b = 0;
|
profile->key_r = profile->key_g = profile->key_b = 0;
|
||||||
|
profile->alpha = 0;
|
||||||
profile->numcolors = 0;
|
profile->numcolors = 0;
|
||||||
profile->bits = 1;
|
profile->bits = 1;
|
||||||
}
|
}
|
||||||
@ -3622,8 +3622,8 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
|
|||||||
if(a != 65535 && (a != 0 || (profile->key && !matchkey)))
|
if(a != 65535 && (a != 0 || (profile->key && !matchkey)))
|
||||||
{
|
{
|
||||||
profile->alpha = 1;
|
profile->alpha = 1;
|
||||||
|
profile->key = 0;
|
||||||
alpha_done = 1;
|
alpha_done = 1;
|
||||||
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
|
||||||
}
|
}
|
||||||
else if(a == 0 && !profile->alpha && !profile->key)
|
else if(a == 0 && !profile->alpha && !profile->key)
|
||||||
{
|
{
|
||||||
@ -3636,6 +3636,7 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
|
|||||||
{
|
{
|
||||||
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
||||||
profile->alpha = 1;
|
profile->alpha = 1;
|
||||||
|
profile->key = 0;
|
||||||
alpha_done = 1;
|
alpha_done = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3651,6 +3652,7 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
|
|||||||
{
|
{
|
||||||
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
||||||
profile->alpha = 1;
|
profile->alpha = 1;
|
||||||
|
profile->key = 0;
|
||||||
alpha_done = 1;
|
alpha_done = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3684,6 +3686,7 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
|
|||||||
if(a != 255 && (a != 0 || (profile->key && !matchkey)))
|
if(a != 255 && (a != 0 || (profile->key && !matchkey)))
|
||||||
{
|
{
|
||||||
profile->alpha = 1;
|
profile->alpha = 1;
|
||||||
|
profile->key = 0;
|
||||||
alpha_done = 1;
|
alpha_done = 1;
|
||||||
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
||||||
}
|
}
|
||||||
@ -3698,6 +3701,7 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
|
|||||||
{
|
{
|
||||||
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
||||||
profile->alpha = 1;
|
profile->alpha = 1;
|
||||||
|
profile->key = 0;
|
||||||
alpha_done = 1;
|
alpha_done = 1;
|
||||||
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
||||||
}
|
}
|
||||||
@ -3734,7 +3738,9 @@ unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
|
|||||||
{
|
{
|
||||||
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
/* Color key cannot be used if an opaque pixel also has that RGB color. */
|
||||||
profile->alpha = 1;
|
profile->alpha = 1;
|
||||||
|
profile->key = 0;
|
||||||
alpha_done = 1;
|
alpha_done = 1;
|
||||||
|
if(profile->bits < 8) profile->bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3760,7 +3766,7 @@ unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
|
|||||||
{
|
{
|
||||||
LodePNGColorProfile prof;
|
LodePNGColorProfile prof;
|
||||||
unsigned error = 0;
|
unsigned error = 0;
|
||||||
unsigned i, n, palettebits, grey_ok, palette_ok;
|
unsigned i, n, palettebits, palette_ok;
|
||||||
|
|
||||||
lodepng_color_profile_init(&prof);
|
lodepng_color_profile_init(&prof);
|
||||||
error = lodepng_get_color_profile(&prof, image, w, h, mode_in);
|
error = lodepng_get_color_profile(&prof, image, w, h, mode_in);
|
||||||
@ -3770,14 +3776,14 @@ unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
|
|||||||
if(prof.key && w * h <= 16)
|
if(prof.key && w * h <= 16)
|
||||||
{
|
{
|
||||||
prof.alpha = 1; /*too few pixels to justify tRNS chunk overhead*/
|
prof.alpha = 1; /*too few pixels to justify tRNS chunk overhead*/
|
||||||
|
prof.key = 0;
|
||||||
if(prof.bits < 8) prof.bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
if(prof.bits < 8) prof.bits = 8; /*PNG has no alphachannel modes with less than 8-bit per channel*/
|
||||||
}
|
}
|
||||||
grey_ok = !prof.colored && !prof.alpha; /*grey without alpha, with potentially low bits*/
|
|
||||||
n = prof.numcolors;
|
n = prof.numcolors;
|
||||||
palettebits = n <= 2 ? 1 : (n <= 4 ? 2 : (n <= 16 ? 4 : 8));
|
palettebits = n <= 2 ? 1 : (n <= 4 ? 2 : (n <= 16 ? 4 : 8));
|
||||||
palette_ok = n <= 256 && (n * 2 < w * h) && prof.bits <= 8;
|
palette_ok = n <= 256 && prof.bits <= 8;
|
||||||
if(w * h < n * 2) palette_ok = 0; /*don't add palette overhead if image has only a few pixels*/
|
if(w * h < n * 2) palette_ok = 0; /*don't add palette overhead if image has only a few pixels*/
|
||||||
if(grey_ok && prof.bits <= palettebits) palette_ok = 0; /*grey is less overhead*/
|
if(!prof.colored && prof.bits <= palettebits) palette_ok = 0; /*grey is less overhead*/
|
||||||
|
|
||||||
if(palette_ok)
|
if(palette_ok)
|
||||||
{
|
{
|
||||||
@ -3806,7 +3812,7 @@ unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
|
|||||||
mode_out->colortype = prof.alpha ? (prof.colored ? LCT_RGBA : LCT_GREY_ALPHA)
|
mode_out->colortype = prof.alpha ? (prof.colored ? LCT_RGBA : LCT_GREY_ALPHA)
|
||||||
: (prof.colored ? LCT_RGB : LCT_GREY);
|
: (prof.colored ? LCT_RGB : LCT_GREY);
|
||||||
|
|
||||||
if(prof.key && !prof.alpha)
|
if(prof.key)
|
||||||
{
|
{
|
||||||
unsigned mask = (1u << mode_out->bitdepth) - 1u; /*profile always uses 16-bit, mask converts it*/
|
unsigned mask = (1u << mode_out->bitdepth) - 1u; /*profile always uses 16-bit, mask converts it*/
|
||||||
mode_out->key_r = prof.key_r & mask;
|
mode_out->key_r = prof.key_r & mask;
|
||||||
|
10
external/lodepng/lodepng.h
vendored
10
external/lodepng/lodepng.h
vendored
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
LodePNG version 20160501
|
LodePNG version 20161127
|
||||||
|
|
||||||
Copyright (c) 2005-2016 Lode Vandevenne
|
Copyright (c) 2005-2016 Lode Vandevenne
|
||||||
|
|
||||||
@ -559,11 +559,11 @@ Used internally by default if "auto_convert" is enabled. Public because it's use
|
|||||||
typedef struct LodePNGColorProfile
|
typedef struct LodePNGColorProfile
|
||||||
{
|
{
|
||||||
unsigned colored; /*not greyscale*/
|
unsigned colored; /*not greyscale*/
|
||||||
unsigned key; /*if true, image is not opaque. Only if true and alpha is false, color key is possible.*/
|
unsigned key; /*image is not opaque and color key is possible instead of full alpha*/
|
||||||
unsigned short key_r; /*these values are always in 16-bit bitdepth in the profile*/
|
unsigned short key_r; /*key values, always as 16-bit, in 8-bit case the byte is duplicated, e.g. 65535 means 255*/
|
||||||
unsigned short key_g;
|
unsigned short key_g;
|
||||||
unsigned short key_b;
|
unsigned short key_b;
|
||||||
unsigned alpha; /*alpha channel or alpha palette required*/
|
unsigned alpha; /*image is not opaque and alpha channel or alpha palette required*/
|
||||||
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16.*/
|
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16.*/
|
||||||
unsigned char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
|
unsigned char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
|
||||||
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for greyscale only. 16 if 16-bit per channel required.*/
|
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for greyscale only. 16 if 16-bit per channel required.*/
|
||||||
@ -896,6 +896,7 @@ TODO:
|
|||||||
[X] let the "isFullyOpaque" function check color keys and transparent palettes too
|
[X] let the "isFullyOpaque" function check color keys and transparent palettes too
|
||||||
[X] better name for the variables "codes", "codesD", "codelengthcodes", "clcl" and "lldl"
|
[X] better name for the variables "codes", "codesD", "codelengthcodes", "clcl" and "lldl"
|
||||||
[ ] don't stop decoding on errors like 69, 57, 58 (make warnings)
|
[ ] don't stop decoding on errors like 69, 57, 58 (make warnings)
|
||||||
|
[ ] make warnings like: oob palette, checksum fail, data after iend, wrong/unknown crit chunk, no null terminator in text, ...
|
||||||
[ ] let the C++ wrapper catch exceptions coming from the standard library and return LodePNG error codes
|
[ ] let the C++ wrapper catch exceptions coming from the standard library and return LodePNG error codes
|
||||||
[ ] allow user to provide custom color conversion functions, e.g. for premultiplied alpha, padding bits or not, ...
|
[ ] allow user to provide custom color conversion functions, e.g. for premultiplied alpha, padding bits or not, ...
|
||||||
[ ] allow user to give data (void*) to custom allocator
|
[ ] allow user to give data (void*) to custom allocator
|
||||||
@ -1607,6 +1608,7 @@ yyyymmdd.
|
|||||||
Some changes aren't backwards compatible. Those are indicated with a (!)
|
Some changes aren't backwards compatible. Those are indicated with a (!)
|
||||||
symbol.
|
symbol.
|
||||||
|
|
||||||
|
*) 27 nov 2016: grey+alpha auto color model detection bugfix
|
||||||
*) 18 apr 2016: Changed qsort to custom stable sort (for platforms w/o qsort).
|
*) 18 apr 2016: Changed qsort to custom stable sort (for platforms w/o qsort).
|
||||||
*) 09 apr 2016: Fixed colorkey usage detection, and better file loading (within
|
*) 09 apr 2016: Fixed colorkey usage detection, and better file loading (within
|
||||||
the limits of pure C90).
|
the limits of pure C90).
|
||||||
|
Loading…
Reference in New Issue
Block a user