Service.java 文件源码

java
阅读 40 收藏 0 点赞 0 评论 0

项目:Pocket-Plays-for-Twitch 作者:
public static Bitmap makeTransparent(Bitmap bit, int transparentColor) {
    int width =  bit.getWidth();
    int height = bit.getHeight();
    Bitmap myBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    int [] allpixels = new int [ myBitmap.getHeight()*myBitmap.getWidth()];
    bit.getPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());
    myBitmap.setPixels(allpixels, 0, width, 0, 0, width, height);

    for(int i =0; i<myBitmap.getHeight()*myBitmap.getWidth();i++){
        if( allpixels[i] == transparentColor)
            allpixels[i] = Color.alpha(Color.TRANSPARENT);
    }

    myBitmap.setPixels(allpixels, 0, myBitmap.getWidth(), 0, 0, myBitmap.getWidth(), myBitmap.getHeight());
    return myBitmap;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号