protected override void OnDraw (Canvas canvas) { int sc = canvas.SaveLayer(mBoundsF, mCopyPaint, SaveFlags.HasAlphaLayer | SaveFlags.FullColorLayer); mMaskDrawable.Draw(canvas); canvas.SaveLayer(mBoundsF, mMaskedPaint, 0); base.OnDraw(canvas); canvas.RestoreToCount(sc); mBorderDrawable.Draw(canvas); }
protected override void OnDraw(Canvas canvas) { Android.Graphics.Drawable.Drawable drawable = GetDrawable(); if (drawable is BitmapDrawable) { RectF rectF = new RectF(drawable.GetBounds()); int restoreCount = canvas.SaveLayer(rectF, null, Canvas.AllSaveFlag); GetImageMatrix().MapRect(rectF); Paint paint = ((BitmapDrawable)drawable).GetPaint(); paint.SetAntiAlias(true); paint.SetColor(unchecked((int)(0xff000000))); canvas.DrawARGB(0, 0, 0, 0); canvas.DrawRoundRect(rectF, Radius, Radius, paint); Xfermode restoreMode = paint.GetXfermode(); paint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcIn)); base.OnDraw(canvas); // Restore paint and canvas paint.SetXfermode(restoreMode); canvas.RestoreToCount(restoreCount); } else { base.OnDraw(canvas); } }