VirtualBox

source: vbox/trunk/src/libs/libpng-1.6.45/contrib/tools/sRGB.h@ 108378

最後變更 在這個檔案從108378是 103316,由 vboxsync 提交於 14 月 前

libpng-1.6.42: Applied and adjusted our libpng changes to 1.6.42. bugref:8515

  • 屬性 svn:eol-style 設為 native
檔案大小: 1.1 KB
 
1/* sRGB.h
2 *
3 * COPYRIGHT: Written by John Cunningham Bowler, 2013.
4 * To the extent possible under law, the author has waived all copyright and
5 * related or neighboring rights to this work. This work is published from:
6 * United States.
7 *
8 * Utility file; not actually a header, this contains definitions of sRGB
9 * calculation functions for inclusion in those test programs that need them.
10 *
11 * All routines take and return a floating point value in the range
12 * 0 to 1.0, doing a calculation according to the sRGB specification
13 * (in fact the source of the numbers is the wikipedia article at
14 * https://en.wikipedia.org/wiki/SRGB).
15 */
16
17static double
18sRGB_from_linear(double l)
19{
20 if (l <= 0.0031308)
21 l *= 12.92;
22
23 else
24 l = 1.055 * pow(l, 1/2.4) - 0.055;
25
26 return l;
27}
28
29static double
30linear_from_sRGB(double s)
31{
32 if (s <= 0.04045)
33 return s / 12.92;
34
35 else
36 return pow((s+0.055)/1.055, 2.4);
37}
38
39static double
40YfromRGB(double r, double g, double b)
41{
42 /* Use the sRGB (rounded) coefficients for Rlinear, Glinear, Blinear to get
43 * the CIE Y value (also linear).
44 */
45 return 0.2126 * r + 0.7152 * g + 0.0722 * b;
46}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette