首页 arrow 开发技术 arrow 程序设计 arrow 半透明图片实现
半透明图片实现
Author Author: 一滴蔚蓝色 | Date Date: 2008-05-11 | View Count View: 863 | Section & Category 开发技术 - 程序设计 | Digg Digg: 0
//获得半透明图片,透明度从0到10共分为11个等级
public static final Image alfImage(Image img,int alf){
    if(img == null){
        System.out.println("alfImage");
        return null;
    }
    if(alf < 0)
        alf = 0;
    else if(alf > 10)
        alf = 10;
    int imgW = img.getWidth();
    int imgH = img.getHeight();
    int[] RGBData = new int[imgW*imgH];
    img.getRGB(RGBData,0,imgW,0,0,imgW,imgH);
    int tmp = ((alf*255/10) << 24)|0x00ffffff;
    for(int i=0;i<RGBData.length;i++)
        RGBData &= tmp;
    Image o_Img = Image.createRGBImage(RGBData,imgW,imgH,true);
    return o_Img;
}

更多阅读:

 

尚无评论发表

我要发表评论

登录菜单

最新文章

订阅本站

RSS 0.91 RSS 1.0 RSS 2.0 ATOM 0.3 OPML