03-06-2010, 08:57 AM
Code:
public void setAlpha(int alpha, int width, int height) {
if (alpha < 0)
alpha = 0;
else if (alpha > 100)
alpha = 100;
alpha *= 2.55;
int w = width;
int h = height;
int[] pixels = new int[w * h];
pixels = this.image.getRGB(0, 0, w, h, pixels, 0, w);
for(int i = 0; i < pixels.length; i++)
pixels[i] = ((pixels[i] == 0) ? 0 << 24 : alpha << 24) | (pixels[i] & 0xffffff);
this.image.setRGB(0, 0, w, h, pixels, 0, w);
}
Enjoy, rofl.