C# OpenXML方案颜色转换-应用<;答:伽马>;及<;a:invgamma>;
处理打开的xml文档时,颜色可以对基础颜色应用各种转换以生成相对颜色。例如,C# OpenXML方案颜色转换-应用<;答:伽马>;及<;a:invgamma>;,c#,openxml,drawingml,C#,Openxml,Drawingml,处理打开的xml文档时,颜色可以对基础颜色应用各种转换以生成相对颜色。例如,会将基色饱和度修改25%。有两种转换我只能找到很少的信息,它们是: <a:gamma> 文档中说“此元素指定生成应用程序渲染的输出颜色应为输入颜色的sRGB gamma偏移。” 及 文档中说“这个元素指定生成应用程序渲染的输出颜色应该是输入颜色的反sRGB伽马偏移。” 我想了解我必须对基础颜色进行什么计算,才能使用这些变换中的任何一种进行变换。有人知道了吗?是的。简言之 这里还有一个VBA版本
会将基色饱和度修改25%。有两种转换我只能找到很少的信息,它们是:
<a:gamma>
文档中说“此元素指定生成应用程序渲染的输出颜色应为输入颜色的sRGB gamma偏移。”
及
文档中说“这个元素指定生成应用程序渲染的输出颜色应该是输入颜色的反sRGB伽马偏移。”
我想了解我必须对基础颜色进行什么计算,才能使用这些变换中的任何一种进行变换。有人知道了吗?是的。简言之
这里还有一个VBA版本:
Public Function sRGB_to_linearRGB(value As Double) If value < 0# Then sRGB_to_linearRGB = 0# Exit Function End If If value <= 0.04045 Then sRGB_to_linearRGB = value / 12.92 Exit Function End If If value <= 1# Then sRGB_to_linearRGB = ((value + 0.055) / 1.055) ^ 2.4 Exit Function End If sRGB_to_linearRGB = 1# End Function Public Function linearRGB_to_sRGB(value As Double) If value < 0# Then linearRGB_to_sRGB = 0# Exit Function End If If value <= 0.0031308 Then linearRGB_to_sRGB = value * 12.92 Exit Function End If If value < 1# Then linearRGB_to_sRGB = 1.055 * (value ^ (1# / 2.4)) - 0.055 Exit Function End If linearRGB_to_sRGB = 1# End Function
公共函数sRGB\u到\u linearRGB(值为双精度) 如果值<0#则 sRGB_至_linearRGB=0# 退出功能 如果结束 如果值
Public Function sRGB_to_linearRGB(value As Double) If value < 0# Then sRGB_to_linearRGB = 0# Exit Function End If If value <= 0.04045 Then sRGB_to_linearRGB = value / 12.92 Exit Function End If If value <= 1# Then sRGB_to_linearRGB = ((value + 0.055) / 1.055) ^ 2.4 Exit Function End If sRGB_to_linearRGB = 1# End Function Public Function linearRGB_to_sRGB(value As Double) If value < 0# Then linearRGB_to_sRGB = 0# Exit Function End If If value <= 0.0031308 Then linearRGB_to_sRGB = value * 12.92 Exit Function End If If value < 1# Then linearRGB_to_sRGB = 1.055 * (value ^ (1# / 2.4)) - 0.055 Exit Function End If linearRGB_to_sRGB = 1# End Function