3 #include "gdipp_lib/scoped_rw_lock.h"
10 for (std::map
<double, BYTE
*>::const_iterator iter
= _gamma_ramps
.begin(); iter
!= _gamma_ramps
.end(); ++iter
)
11 delete[] iter
->second
;
14 const BYTE
*gamma::get_ramp(double gamma
)
16 std::map
<double, BYTE
*>::const_iterator iter
= _gamma_ramps
.find(gamma
);
17 if (iter
== _gamma_ramps
.end())
20 const scoped_rw_lock
lock_w(scoped_rw_lock::CLIENT_GAMMA
, false);
21 iter
= _gamma_ramps
.find(gamma
);
22 if (iter
== _gamma_ramps
.end())
26 return _gamma_ramps
[gamma
];
29 void gamma::init_ramp(double gamma
)
31 BYTE
*new_ramp
= new BYTE
[256];
32 const double gamma_inv
= 1 / gamma
;
34 for (int i
= 0; i
< 256; ++i
)
36 double a
= pow(i
/ 255.0, gamma
);
37 new_ramp
[i
] = static_cast<BYTE
>((pow(i
/ 255.0, gamma_inv
) * 255));
40 _gamma_ramps
[gamma
] = new_ramp
;