public void ColorAlphaGel String name int int r1 int g1 int b1 Image i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public void ColorAlphaGel(String name, int a, int r1, int g1, int b1) {
Image img = (Image) gelHashtable.get(name);
if (img == null) {
return;
}
int color = (0xff << 24) | (r1 << 16) | (g1 << 8) | b1;
int w = img.getWidth();
int h = img.getHeight();
int length = w * h;
int[] rgbData = new int[length];
img.getRGB(rgbData, 0, w, 0, 0, w, h);
int pixel, r, g, b;
for (int k = 0; k < length; k++) {
pixel = rgbData[k];
if (pixel == color) {
r = (pixel >> 16) & 0xff;
g = (pixel >> 8) & 0xff;
b = pixel & 0xff;
rgbData[k] = (a << 24) | ((r << 16) | (g << 8) | b);
}
}
gelHashtable.put(name, Image.createRGBImage(rgbData, w, h, true));
}