- LAC_NO, /*use color type user requested*/
- LAC_ALPHA, /*use color type user requested, but if only opaque pixels and RGBA or grey+alpha, use RGB or grey*/
- LAC_AUTO, /*use PNG color type that can losslessly represent the uncompressed image the smallest possible*/
- /*
- like AUTO, but do not choose 1, 2 or 4 bit per pixel types.
- sometimes a PNG image compresses worse if less than 8 bits per pixels.
- */
- LAC_AUTO_NO_NIBBLES,
- /*
- like AUTO, but never choose palette color type. For small images, encoding
- the palette may take more bytes than what is gained. Note that AUTO also
- already prevents encoding the palette for extremely small images, but that may
- not be sufficient because due to the compression it cannot predict when to
- switch.
- */
- LAC_AUTO_NO_PALETTE,
- LAC_AUTO_NO_NIBBLES_NO_PALETTE
-} LodePNGAutoConvert;
-
+ unsigned colored; /*not greyscale*/
+ unsigned key; /*if true, image is not opaque. Only if true and alpha is false, color key is possible.*/
+ unsigned short key_r; /*these values are always in 16-bit bitdepth in the profile*/
+ unsigned short key_g;
+ unsigned short key_b;
+ unsigned alpha; /*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 bits; /*bits per channel (not for palette). 1,2 or 4 for greyscale only. 16 if 16-bit per channel required.*/
+} LodePNGColorProfile;
+
+void lodepng_color_profile_init(LodePNGColorProfile* profile);
+
+/*Get a LodePNGColorProfile of the image.*/
+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. grey if only grey pixels, palette if < 256 colors, ...*/
+unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
+ const unsigned char* image, unsigned w, unsigned h,
+ const LodePNGColorMode* mode_in);