Dolda2000 GitWeb
/
kaka
/
cakelight.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added gamma correction
[kaka/cakelight.git]
/
src
/
kaka
/
cakelight
/
Color.java
diff --git
a/src/kaka/cakelight/Color.java
b/src/kaka/cakelight/Color.java
index
1e92da9
..
0756209
100644
(file)
--- a/
src/kaka/cakelight/Color.java
+++ b/
src/kaka/cakelight/Color.java
@@
-1,6
+1,14
@@
package kaka.cakelight;
public class Color {
package kaka.cakelight;
public class Color {
+ private static int[] gammaCorrection = new int[256];
+
+ public static void calculateGammaCorrection(double gamma) {
+ for (int i = 0, max = 255; i <= max; i++) {
+ gammaCorrection[i] = (int)(Math.pow((double)i / max, gamma) * max);
+ }
+ }
+
private int r, g, b;
public static Color rgb(double r, double g, double b) {
private int r, g, b;
public static Color rgb(double r, double g, double b) {
@@
-35,15
+43,15
@@
public class Color {
}
public int r() {
}
public int r() {
- return
r
;
+ return
gammaCorrection[r]
;
}
public int g() {
}
public int g() {
- return g;
+ return g
ammaCorrection[g]
;
}
public int b() {
}
public int b() {
- return
b
;
+ return
gammaCorrection[b]
;
}
public Color interpolate(Color other, double value) {
}
public Color interpolate(Color other, double value) {