Skip to content

Commit 720203f

Browse files
committed
revert closestColor changes
1 parent 9ab4f68 commit 720203f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/main/java/bwapi/Color.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,9 @@ public class Color {
9696
RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, RGBRESERVE, new RGBQUAD(255, 255, 255)
9797
};
9898

99+
private static boolean rgbInitialized;
99100
private static final byte[][][] closestColor = new byte[64][64][64];
100101

101-
static {
102-
for (int r = 0; r < 64; ++r) {
103-
for (int g = 0; g < 64; ++g) {
104-
for (int b = 0; b < 64; ++b) {
105-
closestColor[r][g][b] = (byte) getBestIdFor(r << 2, g << 2, b << 2);
106-
}
107-
}
108-
}
109-
}
110-
111102
public final int id;
112103

113104
/**
@@ -159,6 +150,16 @@ private static int getBestIdFor(final int red, final int green, final int blue)
159150
}
160151

161152
private static int getRGBIndex(final int red, final int green, final int blue) {
153+
if (!rgbInitialized) {
154+
rgbInitialized = true;
155+
for (int r = 0; r < 64; ++r) {
156+
for (int g = 0; g < 64; ++g) {
157+
for (int b = 0; b < 64; ++b) {
158+
closestColor[r][g][b] = (byte) getBestIdFor(r << 2, g << 2, b << 2);
159+
}
160+
}
161+
}
162+
}
162163
return closestColor[(byte) (red >> 2)][(byte) (green >> 2)][(byte) (blue >> 2)];
163164
}
164165

0 commit comments

Comments
 (0)