/** * Convert color transformations in {@link ColorStyle} to a {@link Color} instance * * @see <a href="https://msdn.microsoft.com/en-us/library/dd560821%28v=office.12%29.aspx">Using Office Open XML to Customize Document Formatting in the 2007 Office System</a> * @see <a href="https://social.msdn.microsoft.com/Forums/office/en-US/040e0a1f-dbfe-4ce5-826b-38b4b6f6d3f7/saturation-modulation-satmod">saturation modulation (satMod)</a> * @see <a href="http://stackoverflow.com/questions/6754127/office-open-xml-satmod-results-in-more-than-100-saturation">Office Open XML satMod results in more than 100% saturation</a> */ public static Color applyColorTransform(ColorStyle color){ // TODO: The colors don't match 100% the results of Powerpoint, maybe because we still // operate in sRGB and not scRGB ... work in progress ... if (color == null || color.getColor() == null) { return TRANSPARENT; } Color result = color.getColor(); double alpha = getAlpha(result, color); double[] hsl = RGB2HSL(result); // values are in the range [0..100] (usually ...) applyHslModOff(hsl, 0, color.getHueMod(), color.getHueOff()); applyHslModOff(hsl, 1, color.getSatMod(), color.getSatOff()); applyHslModOff(hsl, 2, color.getLumMod(), color.getLumOff()); applyShade(hsl, color); applyTint(hsl, color); result = HSL2RGB(hsl[0], hsl[1], hsl[2], alpha); return result; }
/** * Convert color transformations in {@link ColorStyle} to a {@link Color} instance * * @see <a href="https://msdn.microsoft.com/en-us/library/dd560821%28v=office.12%29.aspx">Using Office Open XML to Customize Document Formatting in the 2007 Office System</a> * @see <a href="https://social.msdn.microsoft.com/Forums/office/en-US/040e0a1f-dbfe-4ce5-826b-38b4b6f6d3f7/saturation-modulation-satmod">saturation modulation (satMod)</a> * @see <a href="http://stackoverflow.com/questions/6754127/office-open-xml-satmod-results-in-more-than-100-saturation">Office Open XML satMod results in more than 100% saturation</a> */ public static Color applyColorTransform(ColorStyle color){ // TODO: The colors don't match 100% the results of Powerpoint, maybe because we still // operate in sRGB and not scRGB ... work in progress ... if (color == null || color.getColor() == null) { return TRANSPARENT; } Color result = color.getColor(); double alpha = getAlpha(result, color); double[] hsl = RGB2HSL(result); // values are in the range [0..100] (usually ...) applyHslModOff(hsl, 0, color.getHueMod(), color.getHueOff()); applyHslModOff(hsl, 1, color.getSatMod(), color.getSatOff()); applyHslModOff(hsl, 2, color.getLumMod(), color.getLumOff()); applyShade(hsl, color); applyTint(hsl, color); result = HSL2RGB(hsl[0], hsl[1], hsl[2], alpha); return result; }