我有源代码,留下mail 我给你发过去

解决方案 »

  1.   

    import java.applet.*;import java.awt.*;import java.awt.image.* ;import java.awt.event.*;public class RGBImageFilterTest extends Applet {Image img = null ;Image img2 = null ;public void init() {MediaTracker mt = new MediaTracker(this) ;try {img = Toolkit.getDefaultToolkit().getImage("../test.gif") ;mt.addImage(img, 0) ;mt.waitForID(0) ;}catch (Exception e) {e.printStackTrace() ;}
    int w = img.getWidth(this) ;int h = img.getHeight(this) ;
    ImageFilter imgFilter = new TransparentImageFilter(w, h) ;FilteredImageSource fImgSource = new FilteredImageSource(img.getSource(), imgFilter) ;img2 = this.createImage(fImgSource) ;}
    public void paint(Graphics g) {g.drawImage(img, 0, 0, this) ;g.drawImage(img2, 100, 100, this) ;}}/*** RGBImageFilter Extends Class - TransparentImageFilter*/
    class TransparentImageFilter extends RGBImageFilter {
    private int width = 0 ;private int height = 0 ;
    public TransparentImageFilter(int width, int height) {this.width = width ;this.height = height ;}
    public int filterRGB(int x, int y, int rgb) {DirectColorModel cm = (DirectColorModel)ColorModel.getRGBdefault() ;int alpha = cm.getAlpha(rgb) ;int red = cm.getRed(rgb) ;int green = cm.getGreen(rgb) ;int blue = cm.getBlue(rgb) ;
    alpha = 255 * y / height ;return alpha << 24 | red << 16 | green << 8 | blue ;} }class TransparentImageFilter extends RGBImageFilter {
    private int width = 0 ;private int height = 0 ;
    public TransparentImageFilter(int width, int height) {canFilterIndexColorModel = true ; // 添加的代码this.width = width ;this.height = height ;}
    public int filterRGB(int x, int y, int rgb) {DirectColorModel cm = (DirectColorModel)ColorModel.getRGBdefault() ;int alpha = cm.getAlpha(rgb) ;int red = cm.getRed(rgb) ;int green = cm.getGreen(rgb) ;int blue = cm.getBlue(rgb) ;
    alpha = 80 ; // 修改的代码return alpha << 24 | red << 16 | green << 8 | blue ;} }public int filterRGB(int x, int y, int rgb){DirectColorModel cm = (DirectColorModel)ColorModel.getRGBdefault() ;int alpha = cm.getAlpha(rgb) ;int red = cm.getRed(rgb) ;int green = cm.getGreen(rgb) ;int blue = cm.getBlue(rgb) ;
    if (red == 255 && green ==255 && blue == 255)alpha = 0 ;return alpha << 24 | red << 16 | green << 8 | blue ;}
      

  2.   

    我有非常完善的应用,要吗?[email protected]
      

  3.   

    [email protected]
    谢谢拉
    :)