OpenXML Schema Conversion Schemes - using <a: gamma> and <a: invgamma>

When processing an open XML document, colors can have various transformations applied to the base color to generate a relative color. For example, it <a:satMod value="25000">will change the saturation of the base colors by 25%. There are two conversions that I could find very little information on, and they are:

<a:gamma> 

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

and

<a:invGamma>

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

I would like to understand what calculation I need to do for the base color in order to transform it using any of these transformations. Has anyone figured this out?

+3
source share
1 answer

Yes. Simply put,

  • <a:gamma>just means taking the sRGB value (0-1 scale) and linearizing it (converting to linear RGB). Take these linear RGB values ​​and save them as sRGB (and, if you want, convert to a range of 0-255).
  • <a:invGamma>- the opposite - take a linear RGB value (0-1 scale) and separate it (convert to sRGB). Take these derivatized RGB values ​​and save them as sRGB (and, if you want, convert to the range 0-255).

, RGB? , Wikipedia 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, , R, G, B 0-1, sRGB, RGB. , 0-1, 0-255, .

+2

Source: https://habr.com/ru/post/1771004/


All Articles