本文整理汇总了Java中android.graphics.Paint.setMaskFilter方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.setMaskFilter方法的具体用法?Java Paint.setMaskFilter怎么用?Java Paint.setMaskFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.setMaskFilter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.graphics.Paint; //导入方法依赖的package包/类
public void init() {
mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mBackgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mBackgroundPaint.setColor(mBackgroudColor);
mFocusPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mFocusPaint.setStyle(Paint.Style.FILL_AND_STROKE);
mFocusPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
if (mBlurRadius > 0)
mFocusPaint.setMaskFilter(new BlurMaskFilter(mBlurRadius, BlurMaskFilter.Blur.NORMAL));
setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
if (mTipsView == null && mTipsViewResId != 0)
mTipsView = LayoutInflater.from(mContext).inflate(mTipsViewResId, this, false);
addView(mTipsView);
setVisibility(View.GONE);
setBackgroundColor(Color.TRANSPARENT);
mTargetView.getViewTreeObserver().addOnGlobalLayoutListener(this);
}
示例2: drawImageDropShadow
import android.graphics.Paint; //导入方法依赖的package包/类
/**
*图片阴影
* @param originalBitmap
*/
public static Drawable drawImageDropShadow(Bitmap originalBitmap, Context context) {
BlurMaskFilter blurFilter = new BlurMaskFilter(3,BlurMaskFilter.Blur.NORMAL);
Paint shadowPaint = new Paint();
shadowPaint.setAlpha(80);
shadowPaint.setColor(context.getResources().getColor(R.color.black));
shadowPaint.setMaskFilter(blurFilter);
int[] offsetXY = new int[2];
Bitmap shadowBitmap = originalBitmap.extractAlpha(shadowPaint, offsetXY);
Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true);
if ( !shadowImage32.isPremultiplied() )
{
shadowImage32.setPremultiplied( true );
}
Canvas c = new Canvas(shadowImage32);
c.drawBitmap(originalBitmap, offsetXY[0], offsetXY[1], null);
return new BitmapDrawable(shadowImage32);
}
示例3: drawShadow
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* 为指定图片增加阴影
*
* @param map 图片
* @param radius 阴影的半径
* @return bitmap
*/
public static Bitmap drawShadow(Bitmap map, int radius) {
if (map == null)
return null;
BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER);
Paint shadowPaint = new Paint();
shadowPaint.setMaskFilter(blurFilter);
int[] offsetXY = new int[2];
Bitmap shadowImage = map.extractAlpha(shadowPaint, offsetXY);
shadowImage = shadowImage.copy(Bitmap.Config.ARGB_8888, true);
Canvas c = new Canvas(shadowImage);
c.drawBitmap(map, -offsetXY[0], -offsetXY[1], null);
return shadowImage;
}
示例4: ShadowGenerator
import android.graphics.Paint; //导入方法依赖的package包/类
private ShadowGenerator(Context context) {
mIconSize = LauncherAppState.getIDP(context).iconBitmapSize;
mCanvas = new Canvas();
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR, Blur.NORMAL));
mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
示例5: createPillWithShadow
import android.graphics.Paint; //导入方法依赖的package包/类
public static Bitmap createPillWithShadow(int rectColor, int width, int height) {
float shadowRadius = height * 1f / 32;
float shadowYOffset = height * 1f / 16;
int radius = height / 2;
Canvas canvas = new Canvas();
Paint blurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
blurPaint.setMaskFilter(new BlurMaskFilter(shadowRadius, Blur.NORMAL));
int centerX = Math.round(width / 2 + shadowRadius);
int centerY = Math.round(radius + shadowRadius + shadowYOffset);
int center = Math.max(centerX, centerY);
int size = center * 2;
Bitmap result = Bitmap.createBitmap(size, size, Config.ARGB_8888);
canvas.setBitmap(result);
int left = center - width / 2;
int top = center - height / 2;
int right = center + width / 2;
int bottom = center + height / 2;
// Draw ambient shadow, center aligned within size
blurPaint.setAlpha(AMBIENT_SHADOW_ALPHA);
canvas.drawRoundRect(left, top, right, bottom, radius, radius, blurPaint);
// Draw key shadow, bottom aligned within size
blurPaint.setAlpha(KEY_SHADOW_ALPHA);
canvas.drawRoundRect(left, top + shadowYOffset, right, bottom + shadowYOffset,
radius, radius, blurPaint);
// Draw the circle
Paint drawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
drawPaint.setColor(rectColor);
canvas.drawRoundRect(left, top, right, bottom, radius, radius, drawPaint);
return result;
}
示例6: init
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* 初始化对象
*/
private void init(Context context) {
tipBitmaps = new ArrayList<>();
targetViews = new ArrayList<>();
rootView = ((Activity) getContext()).findViewById(android.R.id.content);
// 实例化画笔并开启其抗锯齿和抗抖动
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
// 设置画笔透明度为0是关键!
mPaint.setARGB(0, 255, 0, 0);
// 设置混合模式为DST_IN
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
BlurMaskFilter.Blur blurStyle = null;
switch (maskblurstyle) {
case MASKBLURSTYLE_SOLID:
blurStyle = BlurMaskFilter.Blur.SOLID;
break;
case MASKBLURSTYLE_NORMAL:
blurStyle = BlurMaskFilter.Blur.NORMAL;
break;
}
mPaint.setMaskFilter(new BlurMaskFilter(15, blurStyle));
// 生成前景图Bitmap
fgBitmap = Bitmap.createBitmap(screenW, screenH, Bitmap.Config.ARGB_4444);
// 将其注入画布
mCanvas = new Canvas(fgBitmap);
// 绘制前景画布颜色
mCanvas.drawColor(maskColor);
// 实例化箭头图片
jtDownRight = BitmapFactory.decodeResource(getResources(), R.drawable.jt_down_right);
jtDownLeft = BitmapFactory.decodeResource(getResources(), R.drawable.jt_down_left);
jtUpLeft = BitmapFactory.decodeResource(getResources(), R.drawable.jt_up_left);
jtUpRight = BitmapFactory.decodeResource(getResources(), R.drawable.jt_up_right);
}
示例7: initPaint
import android.graphics.Paint; //导入方法依赖的package包/类
private void initPaint()
{
mShadowPaint = new Paint();
mShadowPaint.setColor(mShadowColor);
mShadowPaint.setDither(true); // 抖动处理,会使绘制出来的图片颜色更加平滑和饱满,图像更加清晰 by xiaoxuan 可以屏蔽
mShadowPaint.setMaskFilter(new BlurMaskFilter(mShadowWidth, BlurMaskFilter.Blur.OUTER));
mBorderPaint = new Paint();
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStrokeWidth(mBorderWidth);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setMaskFilter(new BlurMaskFilter(0.5f, BlurMaskFilter.Blur.NORMAL));
}
示例8: createCirclePaint
import android.graphics.Paint; //导入方法依赖的package包/类
private Paint createCirclePaint(Resources resources) {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
blurRadius = resources.getDimension(R.dimen.ame_default_cluster_circle_blur_radius);
if (blurRadius > 0.0f) {
BlurMaskFilter maskFilter = new BlurMaskFilter(blurRadius, BlurMaskFilter.Blur.SOLID);
paint.setMaskFilter(maskFilter);
}
return paint;
}
示例9: initPaints
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Initializes the {@code Paint} objects with the appropriate styles.
*/
private void initPaints() {
mCirclePaint = new Paint();
mCirclePaint.setAntiAlias(true);
mCirclePaint.setDither(true);
mCirclePaint.setColor(mCircleColor);
mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
mCirclePaint.setStyle(Paint.Style.STROKE);
mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
mCirclePaint.setStrokeCap(Paint.Cap.ROUND);
mCircleFillPaint = new Paint();
mCircleFillPaint.setAntiAlias(true);
mCircleFillPaint.setDither(true);
mCircleFillPaint.setColor(mCircleFillColor);
mCircleFillPaint.setStyle(Paint.Style.FILL);
mCircleProgressPaint = new Paint();
mCircleProgressPaint.setAntiAlias(true);
mCircleProgressPaint.setDither(true);
mCircleProgressPaint.setColor(mCircleProgressColor);
mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
mCircleProgressPaint.setStyle(Paint.Style.STROKE);
mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);
mCircleProgressGlowPaint = new Paint();
mCircleProgressGlowPaint.set(mCircleProgressPaint);
mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));
mPointerPaint = new Paint();
mPointerPaint.setAntiAlias(true);
mPointerPaint.setDither(true);
mPointerPaint.setStyle(Paint.Style.FILL);
mPointerPaint.setColor(mPointerColor);
mPointerPaint.setStrokeWidth(mPointerRadius);
mPointerHaloPaint = new Paint();
mPointerHaloPaint.set(mPointerPaint);
mPointerHaloPaint.setColor(mPointerHaloColor);
mPointerHaloPaint.setAlpha(mPointerAlpha);
mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);
mPointerHaloBorderPaint = new Paint();
mPointerHaloBorderPaint.set(mPointerPaint);
mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);
}
示例10: ShadowGenerator
import android.graphics.Paint; //导入方法依赖的package包/类
private ShadowGenerator() {
mIconSize = LauncherAppState.getInstance().getInvariantDeviceProfile().iconBitmapSize;
mCanvas = new Canvas();
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR, Blur.NORMAL));
mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
示例11: initPaints
import android.graphics.Paint; //导入方法依赖的package包/类
/**
* Initializes the {@code Paint} objects with the appropriate styles.
*/
protected void initPaints() {
mCirclePaint = new Paint();
mCirclePaint.setAntiAlias(true);
mCirclePaint.setDither(true);
mCirclePaint.setColor(mCircleColor);
mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
mCirclePaint.setStyle(Paint.Style.STROKE);
mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
mCirclePaint.setStrokeCap(Paint.Cap.ROUND);
mCircleFillPaint = new Paint();
mCircleFillPaint.setAntiAlias(true);
mCircleFillPaint.setDither(true);
mCircleFillPaint.setColor(mCircleFillColor);
mCircleFillPaint.setStyle(Paint.Style.FILL);
mCircleProgressPaint = new Paint();
mCircleProgressPaint.setAntiAlias(true);
mCircleProgressPaint.setDither(true);
mCircleProgressPaint.setColor(mCircleProgressColor);
mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
mCircleProgressPaint.setStyle(Paint.Style.STROKE);
mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);
mCircleProgressGlowPaint = new Paint();
mCircleProgressGlowPaint.set(mCircleProgressPaint);
mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));
mPointerPaint = new Paint();
mPointerPaint.setAntiAlias(true);
mPointerPaint.setDither(true);
mPointerPaint.setStyle(Paint.Style.FILL);
mPointerPaint.setColor(mPointerColor);
mPointerPaint.setStrokeWidth(mPointerRadius);
mPointerHaloPaint = new Paint();
mPointerHaloPaint.set(mPointerPaint);
mPointerHaloPaint.setColor(mPointerHaloColor);
mPointerHaloPaint.setAlpha(mPointerAlpha);
mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);
mPointerHaloBorderPaint = new Paint();
mPointerHaloBorderPaint.set(mPointerPaint);
mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);
}
示例12: initPaint
import android.graphics.Paint; //导入方法依赖的package包/类
private void initPaint() {
//虚线
bgLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
bgLinePaint.setStyle(Paint.Style.STROKE);
bgLinePaint.setColor(Color.parseColor("#ADADAD"));
bgLinePaint.setStrokeWidth(2);
PathEffect effects = new DashPathEffect(new float[]{13, 13}, 5);
bgLinePaint.setPathEffect(effects);
//发光线一号
BlurMaskFilter bmf = new BlurMaskFilter(4, BlurMaskFilter.Blur.SOLID);
linePaint1 = new Paint(Paint.ANTI_ALIAS_FLAG);
linePaint1.setStyle(Paint.Style.STROKE);
linePaint1.setColor(Color.parseColor("#fdeb6b"));
linePaint1.setStrokeWidth(lineWidth);
linePaint1.setMaskFilter(bmf);
//发光线2号
linePaint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
linePaint2.setStyle(Paint.Style.STROKE);
linePaint2.setColor(Color.parseColor("#6effb6"));
linePaint2.setStrokeWidth(lineWidth);
linePaint2.setMaskFilter(bmf);
//标题
titlePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
titlePaint.setTextSize(sp14);
titlePaint.setColor(Color.parseColor("#adadad"));
//数值一号
valuePaint1 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
valuePaint1.setTextSize(sp10);
valuePaint1.setColor(Color.parseColor(COLOR_1));
//数值二号
valuePaint2 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
valuePaint2.setTextSize(sp10);
valuePaint2.setColor(Color.parseColor(COLOR_2));
//文本
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setTextSize(sp10);
textPaint.setColor(Color.WHITE);
//标注
labelPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
labelPaint.setTextSize(sp10);
labelPaint.setColor(Color.parseColor("#adadad"));
//圆点
circlePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
circlePaint.setStyle(Paint.Style.FILL);
circlePaint.setColor(Color.WHITE);
}
示例13: initPaints
import android.graphics.Paint; //导入方法依赖的package包/类
protected void initPaints() {
mCirclePaint = new Paint();
mCirclePaint.setAntiAlias(true);
mCirclePaint.setDither(true);
mCirclePaint.setColor(mCircleColor);
mCirclePaint.setStrokeWidth(mCircleStrokeWidth);
mCirclePaint.setStyle(Paint.Style.STROKE);
mCirclePaint.setStrokeJoin(Paint.Join.ROUND);
mCirclePaint.setStrokeCap(Paint.Cap.ROUND);
mCircleFillPaint = new Paint();
mCircleFillPaint.setAntiAlias(true);
mCircleFillPaint.setDither(true);
mCircleFillPaint.setColor(mCircleFillColor);
mCircleFillPaint.setStyle(Paint.Style.FILL);
mCircleProgressPaint = new Paint();
mCircleProgressPaint.setAntiAlias(true);
mCircleProgressPaint.setDither(true);
mCircleProgressPaint.setColor(mCircleProgressColor);
mCircleProgressPaint.setStrokeWidth(mCircleStrokeWidth);
mCircleProgressPaint.setStyle(Paint.Style.STROKE);
mCircleProgressPaint.setStrokeJoin(Paint.Join.ROUND);
mCircleProgressPaint.setStrokeCap(Paint.Cap.ROUND);
mCircleProgressGlowPaint = new Paint();
mCircleProgressGlowPaint.set(mCircleProgressPaint);
mCircleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * DPTOPX_SCALE), BlurMaskFilter.Blur.NORMAL));
mPointerPaint = new Paint();
mPointerPaint.setAntiAlias(true);
mPointerPaint.setDither(true);
mPointerPaint.setStyle(Paint.Style.FILL);
mPointerPaint.setColor(mPointerColor);
mPointerPaint.setStrokeWidth(mPointerRadius);
mPointerHaloPaint = new Paint();
mPointerHaloPaint.set(mPointerPaint);
mPointerHaloPaint.setColor(mPointerHaloColor);
mPointerHaloPaint.setAlpha(mPointerAlpha);
mPointerHaloPaint.setStrokeWidth(mPointerRadius + mPointerHaloWidth);
mPointerHaloBorderPaint = new Paint();
mPointerHaloBorderPaint.set(mPointerPaint);
mPointerHaloBorderPaint.setStrokeWidth(mPointerHaloBorderWidth);
mPointerHaloBorderPaint.setStyle(Paint.Style.STROKE);
}