import java.awt.image.RGBImageFilter; class AlphaFilter extends RGBImageFilter { int alphaLevel; public AlphaFilter(int alpha) { alphaLevel = alpha; canFilterIndexColorModel = true; } public int filterRGB(int x, int y, int rgb) { int alpha = (rgb >> 24) & 0xff; alpha = (alpha * alphaLevel) / 255; return ((rgb & 0x00ffffff) | (alpha << 24)); } }