Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/lvandeve/lodepng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLode <lvandeve@gmail.com>2019-06-16 01:31:10 +0300
committerLode <lvandeve@gmail.com>2019-06-16 01:31:10 +0300
commit430268baa882a707c36b356402b94ab14dc08b69 (patch)
treef84ee852e640b05d52ecec5f0abc21af4cd1541f /lodepng.h
parentdc871acafc8b7e0823dee123b744c4edf52165d1 (diff)
bugfixes and color stats change
Diffstat (limited to 'lodepng.h')
-rw-r--r--lodepng.h49
1 files changed, 28 insertions, 21 deletions
diff --git a/lodepng.h b/lodepng.h
index 476a206..b891a2c 100644
--- a/lodepng.h
+++ b/lodepng.h
@@ -1,5 +1,5 @@
/*
-LodePNG version 20190210
+LodePNG version 20190615
Copyright (c) 2005-2019 Lode Vandevenne
@@ -660,35 +660,40 @@ typedef enum LodePNGFilterStrategy {
/*Gives characteristics about the integer RGBA colors of the image (count, alpha channel usage, bit depth, ...),
which helps decide which color model to use for encoding.
-Used internally by default if "auto_convert" is enabled. Public because it's useful for custom algorithms.
-NOTE: This is not related to the ICC color profile, search "iccp_profile" instead to find the ICC/chromacity/...
-fields in this header file.*/
-typedef struct LodePNGColorProfile {
+Used internally by default if "auto_convert" is enabled. Public because it's useful for custom algorithms.*/
+typedef struct LodePNGColorStats {
unsigned colored; /*not grayscale*/
unsigned key; /*image is not opaque and color key is possible instead of full alpha*/
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_b;
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 char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
+ unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16 or allow_palette is disabled.*/
+ unsigned char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order, only valid when numcolors is valid*/
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for grayscale only. 16 if 16-bit per channel required.*/
size_t numpixels;
-} LodePNGColorProfile;
-
-void lodepng_color_profile_init(LodePNGColorProfile* profile);
-
-/*Get a LodePNGColorProfile of the image. The profile must already have been inited.
-NOTE: This is not related to the ICC color profile, search "iccp_profile" instead to find the ICC/chromacity/...
-fields in this header file.*/
-unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
- const unsigned char* image, unsigned w, unsigned h,
- const LodePNGColorMode* mode_in);
-/*The function LodePNG uses internally to decide the PNG color with auto_convert.
-Chooses an optimal color model, e.g. gray if only gray pixels, palette if < 256 colors, ...*/
+
+ /*user settings for computing/using the stats*/
+ unsigned allow_palette; /*default 1. if 0, disallow choosing palette colortype in auto_choose_color, and don't count numcolors*/
+ unsigned allow_greyscale; /*default 1. if 0, choose RGB or RGBA even if the image only has gray colors*/
+} LodePNGColorStats;
+
+void lodepng_color_stats_init(LodePNGColorStats* stats);
+
+/*Get a LodePNGColorStats of the image. The stats must already have been inited.*/
+void lodepng_compute_color_stats(LodePNGColorStats* stats,
+ const unsigned char* image, unsigned w, unsigned h,
+ const LodePNGColorMode* mode_in);
+/*Computes a minimal PNG color model that can contain all colors as indicated by the stats and it settings.
+The stats should be computed with lodepng_compute_color_stats.
+mode_in is raw color profile of the image the stats were computed on, to copy palette order from when relevant.
+Minimal PNG color model means the color type and bit depth that gives smallest amount of bits in the output image,
+e.g. gray if only grayscale pixels, palette if less than 256 colors, color key if only single transparent color, ...
+LodePNG uses this function internally if auto_convert is enabled (it is by default).
+*/
unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
- const unsigned char* image, unsigned w, unsigned h,
- const LodePNGColorMode* mode_in);
+ const LodePNGColorMode* mode_in,
+ const LodePNGColorMode* stats);
/*Settings for the encoder.*/
typedef struct LodePNGEncoderSettings {
@@ -1768,6 +1773,8 @@ yyyymmdd.
Some changes aren't backwards compatible. Those are indicated with a (!)
symbol.
+*) 15 jun 2019 (!): auto_choose_color API changed (for bugfix: don't use palette
+ if ICC profile) and non-ICC LodePNGColorProfile renamed to LodePNGColorStats.
*) 30 dec 2018: code style changes only: removed newlines before opening braces.
*) 10 sep 2018: added way to inspect metadata chunks without full decoding.
*) 19 aug 2018 (!): fixed color mode bKGD is encoded with and made it use