具有循环进度视图的Android Mask ImageView

时间:2015-08-06 03:17:12

标签: java android android-layout porter-duff

我正在尝试用CircularProgressView使用PorterDuff.Mode.DST_IN屏蔽图像视图这里是屏蔽的示例代码

 public static Bitmap getMaskedBitmap(Resources res,  int sourceResId,Bitmap mask) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        options.inMutable = true;
    }
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    Bitmap source = BitmapFactory.decodeResource(res, sourceResId, options);
    Bitmap bitmap;
    if (source.isMutable()) {
        bitmap = source;
    } else {
        bitmap = source.copy(Bitmap.Config.ARGB_8888, true);
        source.recycle();
    }
    bitmap.setHasAlpha(true);
    Canvas canvas = new Canvas(bitmap);

    Paint paint = new Paint();
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    canvas.drawBitmap(mask, 0, 0, paint);

    mask.recycle();
    return bitmap;
}

source image =将是一封透明的字母" C"来自像这样的抽象人enter image description here

并且掩码图像应该来自CircularProgressView。我想填写透明字母" C"使用固定的白色基于点(比率为1/10),使用CircularProgressView屏蔽字母C.是否可能?

0 个答案:

没有答案