OpenXML 方案颜色转换 - 应用

发布于 2024-09-29 01:11:09 字数 389 浏览 6 评论 0原文

处理打开的 xml 文档时,颜色可以对基色进行各种变换以生成相对颜色。例如 会将基色饱和度修改 25%。我能找到的信息很少,有两种转换:

<a:gamma> 

文档说“此元素指定生成应用程序渲染的输出颜色应该是输入颜色的 sRGB gamma 偏移。”

并且

<a:invGamma>

文档说“此元素指定生成应用程序渲染的输出颜色应该是输入颜色的逆 sRGB gamma 偏移。”

我想了解我必须对基色进行哪些计算才能使用这些转换中的任何一个来转换它。有人弄清楚这一点了吗?

When processing an open xml document, colors can have various transformations applied to a base color to generate a relative color. For instance <a:satMod value="25000"> would modify the base colors saturation by 25%. There are two transforms I have been able to find very little information on and they are:

<a:gamma> 

The docs say "This element specifies that the output color rendered by the generating application should be the sRGB gamma shift of the input color."

and

<a:invGamma>

The docs say "This element specifies that the output color rendered by the generating application should be the inverse sRGB gamma shift of the input color."

I would like to understand what calculation I would have to do on the base color to transform it using either of these transformations. Has anybody figured this out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我一直都在从未离去 2024-10-06 01:11:09

是的。简单来说,

  • 只是表示获取 sRGB 值(0-1 刻度)并将其线性化(转换为线性 RGB)。获取这些线性 RGB 值并将它们保存为 sRGB(如果需要,可以转换为 0-255 范围)。
  • 则相反 - 获取线性 RGB 值(0-1 刻度)并将其去线性化(转换为 sRGB)。获取这些去线性化的 RGB 值并将它们保存为 sRGB(如果需要,可以转换为 0-255 范围)。

那么什么是线性RGB呢?计算结果位于维基百科的 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 

您传入的 value 是 0-1 范围内的 R、G、B 分量,可以是 sRGB 或线性 RGB。您将收到相同的范围(0-1),然后根据您的需要,您可以转换为 0-255 范围来构建您的颜色。

Yeah. Simply put,

  • <a:gamma> simply means to take the sRGB value (0-1 scale) and linearize it (convert to linear RGB). Take those linear RGB values and save them as sRGB (and convert to 0-255 range if you want).
  • <a:invGamma> is the opposite - take the linear RGB value (0-1 scale) and delinearize it (convert to sRGB). Take those delinearized RGB values and save them as sRGB (and convert to 0-255 range if you want).

So what is linear RGB? The calculation is here on Wikipedia's sRGB page.

Here's also a VBA version:

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 

The value that you pass in is the R, G, B component in 0-1 range, either sRGB or linear RGB. You'll receive the same range back, 0-1, and depending on your needs, you can then convert to 0-255 range to construct your color.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文