Changeset 2195 for trunk/src/lol/image
 Timestamp:
 Jan 2, 2013, 7:08:51 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/lol/image/color.h
r2193 r2195 81 81 82 82 /* 83 * Convert linear HSV to linear HSL 84 */ 85 static vec3 HSVToHSL(vec3 src) 86 { 87 float tmp = (2  src.y) * src.z; 88 return vec3(src.x, src.y * src.z / (1.f  abs(1.f  tmp)), 0.5f * tmp); 89 } 90 91 static vec4 HSVToHSL(vec4 src) 92 { 93 return vec4(HSVToHSL(src.rgb), src.a); 94 } 95 96 /* 97 * Convert linear HSL to linear HSV 98 */ 99 static vec3 HSLToHSV(vec3 src) 100 { 101 float tmp = src.y * (0.5f  abs(0.5f  src.z)); 102 return vec3(src.x, 2.f * tmp / (src.z + tmp), src.z + tmp); 103 } 104 105 static vec4 HSLToHSV(vec4 src) 106 { 107 return vec4(HSLToHSV(src.rgb), src.a); 108 } 109 110 /* 83 111 * Convert linear RGB to CIE XYZ 84 112 */ 85 113 static vec3 LinearRGBToCIEXYZ(vec3 src) 114 { 115 mat3 m(vec3(0.4124f, 0.2126f, 0.0193f), 116 vec3(0.3576f, 0.7152f, 0.1192f), 117 vec3(0.1805f, 0.0722f, 0.9505f)); 118 return m * src; 119 } 120 121 static vec4 LinearRGBToCIEXYZ(vec4 src) 122 { 123 return vec4(LinearRGBToCIEXYZ(src.rgb), src.a); 124 } 125 126 /* 127 * Convert CIE XYZ to linear RGB 128 */ 129 static vec3 CIEXYZToLinearRGB(vec3 src) 86 130 { 87 131 mat3 m(vec3(3.2406f, 0.9689f, 0.0557f), … … 91 135 } 92 136 93 static vec4 LinearRGBToCIEXYZ(vec4 src)94 {95 return vec4(LinearRGBToCIEXYZ(src.rgb), src.a);96 }97 98 /*99 * Convert CIE XYZ to linear RGB100 */101 static vec3 CIEXYZToLinearRGB(vec3 src)102 {103 mat3 m(vec3(0.4124f, 0.2126f, 0.0193f),104 vec3(0.3576f, 0.7152f, 0.1192f),105 vec3(0.1805f, 0.0722f, 0.9505f));106 return m * src;107 }108 109 137 static vec4 CIEXYZToLinearRGB(vec4 src) 110 138 { … … 113 141 114 142 /* 143 * Convert CIE XYZ to CIE xyY 144 */ 145 static vec3 CIEXYZToCIExyY(vec3 src) 146 { 147 float tmp = 1.0f / (src.x + src.y + src.z); 148 return vec3(src.x * tmp, src.y * tmp, src.y); 149 } 150 151 static vec4 CIEXYZToCIExyY(vec4 src) 152 { 153 return vec4(CIEXYZToCIExyY(src.rgb), src.a); 154 } 155 156 /* 115 157 * Convert CIE XYZ to CIE L*a*b* 116 * Note: XYZ values should be normalised, ie. divided by the 117 * corresponding components for white. 158 * Note: XYZ values are normalised using a D65 illuminant. 118 159 */ 119 160 static vec3 CIEXYZToCIELab(vec3 src) … … 123 164 float const c = 4.0 / 29; 124 165 float const d = 1.0 / 3; 166 167 /* Normalise XYZ using D65 illuminant */ 168 src *= vec3(1.f / 95.047f, 1.f / 100.f, 1.f / 108.883f); 125 169 126 170 vec3 f = b * src + vec3(c);
Note: See TracChangeset
for help on using the changeset viewer.