16 #ifndef AGG_GAMMA_FUNCTIONS_INCLUDED 17 #define AGG_GAMMA_FUNCTIONS_INCLUDED 19 #include "agg_basics.h" 26 double operator()(
double x)
const {
return x; }
37 void gamma(
double g) { m_gamma = g; }
38 double gamma()
const {
return m_gamma; }
40 double operator() (
double x)
const 42 return pow(x, m_gamma);
57 void threshold(
double t) { m_threshold = t; }
58 double threshold()
const {
return m_threshold; }
60 double operator() (
double x)
const 62 return (x < m_threshold) ? 0.0 : 1.0;
75 gamma_linear(
double s,
double e) : m_start(s), m_end(e) {}
77 void set(
double s,
double e) { m_start = s; m_end = e; }
78 void start(
double s) { m_start = s; }
79 void end(
double e) { m_end = e; }
80 double start()
const {
return m_start; }
81 double end()
const {
return m_end; }
83 double operator() (
double x)
const 85 if(x < m_start)
return 0.0;
86 if(x > m_end)
return 1.0;
87 return (x - m_start) / (m_end - m_start);
103 void value(
double v) { m_mul = v; }
104 double value()
const {
return m_mul; }
106 double operator() (
double x)
const 108 double y = x * m_mul;
117 inline double sRGB_to_linear(
double x)
119 return (x <= 0.04045) ? (x / 12.92) : pow((x + 0.055) / (1.055), 2.4);
122 inline double linear_to_sRGB(
double x)
124 return (x <= 0.0031308) ? (x * 12.92) : (1.055 * pow(x, 1 / 2.4) - 0.055);