Archive
Background info on libpng warning: iCCP: known incorrect sRGB profile
I was just checking some log file saved from Buildbox and seems Qt framework was logging the error:
libpng warning: iCCP: known incorrect sRGB profile
Did some quick research on Google (sorry dear Bing) and added the following background info to the respective question on StackOverflow:
http://stackoverflow.com/questions/22745076/libpng-warning-iccp-known-incorrect-srgb-profile/
Some changes in libpng version 1.6+ cause it to issue a warning or even not work correctly with the original HP/MS sRGB profile, leading to the following stderr: libpng warning: iCCP: known incorrect sRGB profile The old profile uses a D50 whitepoint, where D65 is standard. This profile is not uncommon, being used by Adobe Photoshop, although it was not embedded into images by default.
(source: https://wiki.archlinux.org/index.php/Libpng_errors)
Error detection in some chunks has improved; in particular the iCCP chunk reader now does pretty complete validation of the basic format. Some bad profiles that were previously accepted are now rejected, in particular the very old broken Microsoft/HP sRGB profile. The PNG spec requirement that only grayscale profiles may appear in images with color type 0 or 4 and that even if the image only contains gray pixels, only RGB profiles may appear in images with color type 2, 3, or 6, is now enforced. The sRGB chunk is allowed to appear in images with any color type.
HowTo: List all known color names and find name of given color at WPF
This is my answer at
http://stackoverflow.com/questions/4475391/wpf-silverlight-find-the-name-of-a-color
Modified answer from Thomas Levesque to populate the Dictionary only when 1st needed, instead of taking the cost at startup (going to use at speech recognition-driven turtle graphics, so that user can pronounce known color names to change the turtle’s pen color)
- //Project: SpeechTurtle (http://SpeechTurtle.codeplex.com)
- //Filename: ColorUtils.cs
- //Version: 20150901
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Windows.Media;
- namespace SpeechTurtle.Utils
- {
- /// <summary>
- /// Color-related utility methods
- /// </summary>
- public static class ColorUtils //based on http://stackoverflow.com/questions/4475391/wpf-silverlight-find-the-name-of-a-color
- {
- #region — Fields —
- private static Dictionary<string, Color> knownColors; //=null
- #endregion
- #region — Methods —
- #region Extension methods
- public static string GetKnownColorName(this Color color)
- {
- return GetKnownColors()
- .Where(kvp => kvp.Value.Equals(color))
- .Select(kvp => kvp.Key)
- .FirstOrDefault();
- }
- public static Color GetKnownColor(this string name)
- {
- Color color;
- return GetKnownColors().TryGetValue(name, out color) ? color : Colors.Black; //if color for name is not found, return black
- }
- #endregion
- public static Dictionary<string, Color> GetKnownColors()
- {
- if (knownColors == null)
- {
- var colorProperties = typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public);
- knownColors = colorProperties.ToDictionary(
- p => p.Name,
- p => (Color)p.GetValue(null, null));
- }
- return knownColors;
- }
- public static string[] GetKnownColorNames()
- {
- return GetKnownColors().Keys.ToArray();
- }
- #endregion
- }
- }