Java 类android.graphics.PaintFlagsDrawFilter 实例源码

项目:stynico    文件:SunLineView.java   
private void init() {
    Log.i(Tag, "init");

    mLineWidth = changeDp(1);
    mLineHeight = changeDp(3);
    mFixLineHeight = changeDp(6);
    mSunRadius = changeDp(12);
    mLineColor = Color.RED;
    mLineLevel = 30;

    //线的配置
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    // 设置画笔宽度
    mLinePaint.setStrokeWidth(mLineWidth);
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    debugRect = new Rect();
    mouthRect = new RectF();
}
项目:MyLife    文件:BuildLayerFrameLayout.java   
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    if (mChanged && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        post(new Runnable() {
            @Override
            public void run() {
                if (mAttached && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    final int layerType = getLayerType();
                    // If it's already a hardware layer, it'll be built anyway.
                    if (layerType != LAYER_TYPE_HARDWARE || mFirst) {
                        mFirst = false;
                        setLayerType(LAYER_TYPE_HARDWARE, null);
                        buildLayer();
                        setLayerType(LAYER_TYPE_NONE, null);
                    }
                }
            }
        });
        mChanged = false;
    }
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
            .FILTER_BITMAP_FLAG);
    canvas.setDrawFilter(pfd);
}
项目:MDWechat    文件:ImageHelper.java   
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
            .getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);
    paint.setDither(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
项目:Cybernet-VPN    文件:BuildLayerFrameLayout.java   
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    if (mChanged && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        post(new Runnable() {
            @Override
            public void run() {
                if (mAttached && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    final int layerType = getLayerType();
                    // If it's already a hardware layer, it'll be built anyway.
                    if (layerType != LAYER_TYPE_HARDWARE || mFirst) {
                        mFirst = false;
                        setLayerType(LAYER_TYPE_HARDWARE, null);
                        buildLayer();
                        setLayerType(LAYER_TYPE_NONE, null);
                    }
                }
            }
        });
        mChanged = false;
    }
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
            .FILTER_BITMAP_FLAG);
    canvas.setDrawFilter(pfd);
}
项目:letv    文件:ViewfinderView.java   
public void onDraw(Canvas canvas) {
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, 3));
    int W = canvas.getWidth();
    int H = canvas.getHeight();
    Rect frame = CameraManager.get().getFramingRect();
    if (frame != null) {
        drawCover(canvas, frame, W, H);
        if (this.resultBitmap != null) {
            canvas.drawBitmap(this.resultBitmap, (float) frame.left, (float) frame.top, this.paint);
            return;
        }
        drawScanningLine(canvas, frame);
        drawRectEdge(canvas, frame);
        this.paint.reset();
        postInvalidateDelayed(ANIMATION_DELAY);
    }
}
项目:CardSwipeLayout    文件:RoundImageView.java   
public RoundImageView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RoundImageView);
    float mRadius = array.getDimension(R.styleable.RoundImageView_radius, 10);
    rids[0] = mRadius;
    rids[1] = mRadius;
    rids[2] = mRadius;
    rids[3] = mRadius;
    rids[4] = 0f;
    rids[5] = 0f;
    rids[6] = 0f;
    rids[7] = 0f;
    array.recycle();
    mPath = new Path();
    paintFlagsDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
    setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
项目:login    文件:ClearEditText.java   
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    if (mAnimator_visible.isRunning()) {
        int x = (int) mAnimator_visible.getAnimatedValue();
        drawClear(x, canvas);
        invalidate();
    } else if (isVisible) {
        drawClear(0, canvas);
    }

    if (mAnimator_gone.isRunning()) {
        float scale = (float) mAnimator_gone.getAnimatedValue();
        drawClearGone(scale, canvas);
        invalidate();
    }
}
项目:SprintNBA    文件:SunLineView.java   
private void init() {
    Log.i(Tag, "init");

    mLineWidth = changeDp(1);
    mLineHeight = changeDp(3);
    mFixLineHeight = changeDp(6);
    mSunRadius = changeDp(12);
    mLineColor = Color.RED;
    mLineLevel = 30;

    //线的配置
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    // 设置画笔宽度
    mLinePaint.setStrokeWidth(mLineWidth);
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    debugRect = new Rect();
    mouthRect = new RectF();
}
项目:BigApp_Discuz_Android    文件:BottomItemView.java   
private void drawTargetBitmap(Canvas canvas,int alpha) {
//        mCanvas =canvas;
        mPaint = new Paint();
        mPaint.setColor(mSelectedColor);
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
        mPaint.setAlpha(alpha);
        mCanvas.drawRect(mIconRect, mPaint);
        mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
        mPaint.setAlpha(255);

        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));

        if (mIconBitmapSelected != null)
            mCanvas.drawBitmap(mIconBitmapSelected, mIconRect.left, mIconRect.top, mPaint);
        else
            mCanvas.drawBitmap(mIconBitmapNormal, mIconRect.left, mIconRect.top, mPaint);
        canvas.drawBitmap(mBitmap, 0, 0, null);

    }
项目:PullRefreshLayout    文件:CircleView.java   
private void init() {
    mStrokeWidth = AppUtil.dip2px(2);
    mPaint = new Paint();
    mPaint.setColor(0xFF0000FF);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(mStrokeWidth);
    mPaint.setAntiAlias(true);
    mPaint.setDither(false);


    mBGPaint = new Paint();
    mBGPaint.setColor(0xFFAAAAAA);
    mBGPaint.setStyle(Paint.Style.STROKE);
    mBGPaint.setStrokeWidth(mStrokeWidth);
    mBGPaint.setAntiAlias(true);
    mBGPaint.setDither(false);
    mDegree = 0;
    pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);
}
项目:collapselrecycler    文件:CircleImageView.java   
/**
 * drawable转bitmap
 *处理不同情况下的图片显示
 * @param drawable
 * @return
 */
private Bitmap drawable2Bitmap(Drawable drawable) {
    int w = drawable.getIntrinsicWidth();
    int h = drawable.getIntrinsicHeight();
    Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    drawable.setBounds(0, 0, w, h);
    if ((w >= h) && CropType.centerTop.equals(cropType)) {
        canvas.translate((h - w) * 0.5F, 0);
    } else if ((w >= h) && CropType.center.equals(cropType)) {
        canvas.translate((h - w) * 0.5F, 0);
    } else if ((w < h) && CropType.center.equals(cropType)) {
        canvas.translate(0, (w - h) * 0.5F);
    }
    drawable.draw(canvas);
    return bitmap;
}
项目:BitkyShop    文件:SunLineView.java   
private void init() {
    Log.i(Tag, "init");

    mLineWidth = changeDp(1);
    mLineHeight = changeDp(3);
    mFixLineHeight = changeDp(6);
    mSunRadius = changeDp(12);
    mLineColor = Color.RED;
    mLineLevel = 30;

    //线的配置
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    // 设置画笔宽度
    mLinePaint.setStrokeWidth(mLineWidth);
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    debugRect = new Rect();
    mouthRect = new RectF();
}
项目:FlowingDrawer    文件:BuildLayerFrameLayout.java   
@Override
protected void dispatchDraw(Canvas canvas) {
    super.dispatchDraw(canvas);
    if (mChanged && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        post(new Runnable() {
            @Override
            public void run() {
                if (mAttached && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    final int layerType = getLayerType();
                    // If it's already a hardware layer, it'll be built anyway.
                    if (layerType != LAYER_TYPE_HARDWARE || mFirst) {
                        mFirst = false;
                        setLayerType(LAYER_TYPE_HARDWARE, null);
                        buildLayer();
                        setLayerType(LAYER_TYPE_NONE, null);
                    }
                }
            }
        });
        mChanged = false;
    }
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
            .FILTER_BITMAP_FLAG);
    canvas.setDrawFilter(pfd);
}
项目:test4XXX    文件:MainActivity.java   
private void drawCircles(Canvas canvas) {
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG));

    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(0xffffffff);

    RectF r = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
    canvas.drawRect(r, paint);

    for (int i = radiusArray.length - 1; i >= 0; i--) {
        if (radiusArray[i] >= baseRadius) {
            paint.setColor(getColor(radiusArray[i]));

            canvas.drawCircle(canvas.getWidth() / 2,
                    canvas.getHeight() / 2, radiusArray[i], paint);
        }
    }

    paint.setColor(Color.argb(255, 0xfe, 0xaa, 0x4b));
    canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2,
            baseRadius, paint);
}
项目:Gizwits-AirPurifier_Android    文件:RoseBoxSeekBarView.java   
/**
 * @param context
 * @param attrs
 * @param defStyle
 */
public RoseBoxSeekBarView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    this.mContext = context;
    mResources = context.getApplicationContext().getResources();
    drawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    int cacheSize = maxMemory / 8;
    mMemoryCache = new LruCache<String, Bitmap>(cacheSize) {
        @Override
        protected int sizeOf(String key, Bitmap bitmap) {
            // 重写此方法来衡量每张图片的大小,默认返回图片数量。
            return bitmap.getByteCount() / 1024;
        }
    };
    // typeface = Typeface.createFromAsset(getContext().getAssets(),
    // "fonts/HELVETICANEUELTSTD-THEX.OTF");

}
项目:AndroidUI    文件:ClearEditText.java   
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));//抗锯齿
    if (mAnimator_visible.isRunning()) {
        int x = (int) mAnimator_visible.getAnimatedValue();
        drawClear(x,canvas);
        invalidate();
    }else if (isVisible){
        drawClear(0,canvas);
    }

    if(mAnimator_gone.isRunning()){
        float scale = (float) mAnimator_gone.getAnimatedValue();
        drawClearGone(scale, canvas);
        invalidate();
    }
}
项目:MiBandDecompiled    文件:LinePieChart.java   
protected void onRectChanged(RectF rectf)
{
    super.onRectChanged(rectf);
    o = new RectF();
    o.left = rectf.centerX() - 15.5F * mDensity;
    o.top = rectf.top + 2.0F * mDensity;
    o.right = o.left + 31F * mDensity;
    o.bottom = o.top + 31F * mDensity;
    p = Bitmap.createBitmap((int)rectf.width(), (int)rectf.height(), android.graphics.Bitmap.Config.ARGB_8888);
    r = false;
    if (q == null)
    {
        q = new Canvas();
        q.setDrawFilter(new PaintFlagsDrawFilter(0, 7));
    }
    q.setBitmap(p);
}
项目:test4android    文件:LineView.java   
@Override
protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    super.onDraw(canvas);

    mPaint.setColor(Color.RED);
    mPaint.setAntiAlias(true);

    for (int index = 0; index < mListPoint.size(); index++)
    {
        if (index > 0)
        {
            canvas.drawLine(mListPoint.get(index - 1).get(X_KEY), mListPoint.get(index - 1)
                    .get(Y_KEY),
                    mListPoint.get(index).get(X_KEY), mListPoint.get(index).get(Y_KEY), mPaint);
            canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
                    | Paint.FILTER_BITMAP_FLAG));
        }
    }
}
项目:MaterialButton    文件:FlatButton.java   
protected void init() {
    bgPaint = new Paint();
    bgPaint.setAntiAlias(true);
    bgPaint.setColor(backgroundColor);

    focusPaint = new Paint();
    focusPaint.setAntiAlias(true);
    focusPaint.setColor(focusColor);

    animatorSet = new AnimatorSet();

    bgRectF = new RectF();

       mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

       this.setBackgroundResource(0);
}
项目:MaterialButton    文件:FloatingActionButton.java   
private void init() {
    defaultPaint = new Paint();
    defaultPaint.setAntiAlias(true);
    defaultPaint.setColor(defaultBgColor);

    focusPaint = new Paint();
    focusPaint.setAntiAlias(true);
    focusPaint.setColor(focusBgcolor);

    icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_new);
    getIconParams();

       mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

       this.setBackgroundResource(0);
}
项目:SinaWeibo_Android    文件:SunLineView.java   
private void init() {
    Log.i(Tag, "init");

    mLineWidth = changeDp(1);
    mLineHeight = changeDp(3);
    mFixLineHeight = changeDp(6);
    mSunRadius = changeDp(12);
    mLineColor = Color.RED;
    mLineLevel = 30;

    //线的配置
    mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
    // 设置画笔宽度
    mLinePaint.setStrokeWidth(mLineWidth);
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    debugRect = new Rect();
    mouthRect = new RectF();
}
项目:SmartMeterWithUI    文件:ControllerWheel.java   
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(final Canvas canvas) {
    Log.d("SMTest onDraw()", "");

    // canvas 抗锯齿
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG));

    drawBG(canvas);
    if (NeedleShow) {
        drawNeedle(canvas);
    }
    drawFG(canvas);
    drawUnit(canvas);
    // drawUnitLine(canvas);
    // drawMyRect(canvas);
}
项目:FlowingSidebarMenu--Android    文件:DrawerLayout.java   
@Override
protected void dispatchDraw(@NonNull Canvas canvas) {
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
            .FILTER_BITMAP_FLAG);
    canvas.setDrawFilter(pfd);
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child == null)
            return;
    }
    super.dispatchDraw(canvas);
}
项目:CXJPadProject    文件:PaintView.java   
/***
 * 初始化
 */
private void init() {
    //关闭硬件加速
    //否则橡皮擦模式下,设置的 PorterDuff.Mode.CLEAR ,实时绘制的轨迹是黑色
    setBackgroundColor(Color.WHITE);//设置白色背景
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    //画笔
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setStrokeWidth(4f);
    mPaint.setAntiAlias(true);
    mPaint.setColor(Color.BLACK);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);//使画笔更加圆润
    mPaint.setStrokeCap(Paint.Cap.ROUND);//同上
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);
    //保存签名的画布
    post(new Runnable() {//拿到控件的宽和高
        @Override
        public void run() {
            //获取PaintView的宽和高
            //由于橡皮擦使用的是 Color.TRANSPARENT ,不能使用RGB-565
            mBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_4444);
            mCanvas = new Canvas(mBitmap);
            //抗锯齿
            mCanvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
            //背景色
            mCanvas.drawColor(Color.WHITE);
        }
    });

    undoList = new LinkedList<>();
    redoList = new LinkedList<>();
}
项目:boohee_v5.6    文件:BooheeRulerView.java   
private void initPaint() {
    this.pfdf = new PaintFlagsDrawFilter(0, 3);
    this.bgPaint = new Paint();
    this.bgPaint.setColor(this.bgColor);
    this.indicatorPaint = new Paint();
    this.indicatorPaint.setColor(this.indicatorColor);
    this.textPaint = new Paint();
    this.textPaint.setColor(this.textColor);
    this.textPaint.setTextSize(this.textSize);
    this.linePaint = new Paint();
    this.linePaint.setColor(this.lineColor);
    this.path = new Path();
}
项目:Mask-Animation    文件:ShadeTriangleTotalForRankView.java   
private void init(Context context, AttributeSet attrs, int defStyle) {
    TypedArray type = context.obtainStyledAttributes(attrs, R.styleable.ShadeTriangleTotalForRankView, 0, 0);
    duration = (long) type.getFloat(R.styleable.ShadeTriangleTotalForRankView_shade_duration, 18000f);
    mImageSource_total = type.getResourceId(R.styleable.ShadeTriangleTotalForRankView_image_total, R.drawable.mask_triangle_total);
    mTotal_bitmap = readBitMap(context, mImageSource_total);
    mPaint_Mask.setStyle(Paint.Style.FILL);
    mPaint_Mask.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    mPaint_Pic.setFilterBitmap(true);
    pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    src = new Rect();
    dst = new Rect();
    path = new Path();

}
项目:libcommon    文件:BrushDrawable.java   
public BrushDrawable(final int type, final int width, final int height, final int clearflags, final int setFlags) {
    super();
    mPaint = new Paint();
    mDrawFilter = new PaintFlagsDrawFilter(clearflags, setFlags);
    mClearXfermode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR);
    init(100, 100);
    setType(type, width, height);
}
项目:RxTools    文件:RxSwipeCaptcha.java   
private Bitmap getMaskBitmap(Bitmap mBitmap, Path mask) {
        //以控件宽高 create一块bitmap
        Bitmap tempBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888);
        Log.e(TAG, " getMaskBitmap: width:" + mBitmap.getWidth() + ",  height:" + mBitmap.getHeight());
        Log.e(TAG, " View: width:" + mWidth + ",  height:" + mHeight);
        //把创建的bitmap作为画板
        Canvas mCanvas = new Canvas(tempBitmap);
        //有锯齿 且无法解决,所以换成XFermode的方法做
        //mCanvas.clipPath(mask);
        // 抗锯齿
        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
        //绘制用于遮罩的圆形
        mCanvas.drawPath(mask, mMaskPaint);
        //设置遮罩模式(图像混合模式)
        mMaskPaint.setXfermode(mPorterDuffXfermode);
//        mMaskPaint.setShadowLayer(5, 3, 3, 0xFF0000FF);

        // 设置光源的方向
        float[] direction = new float[]{ 1, 1, 1 };
//设置环境光亮度
        float light = 1f;
// 选择要应用的反射等级
        float specular = 6;
// 向mask应用一定级别的模糊
        float blur = 3.5f;
//        EmbossMaskFilter emboss=new EmbossMaskFilter(direction,light,specular,blur);
        BlurMaskFilter maskFilter = new BlurMaskFilter(10, BlurMaskFilter.Blur.SOLID);
// 应用mask
        mMaskPaint.setMaskFilter(maskFilter);

        //★考虑到scaleType等因素,要用Matrix对Bitmap进行缩放
        mCanvas.drawBitmap(mBitmap, getImageMatrix(), mMaskPaint);
        mMaskPaint.setXfermode(null);
        return tempBitmap;
    }
项目:BigApp_Discuz_Android    文件:KLineView.java   
/**
 * 创建裁剪的背景图片
 * 
 * @param paint
 * @param path
 * @param bitmap
 * @return
 */
private Bitmap creatBitmap(Paint paint, Path path, Bitmap bitmap) {
    Canvas newCanvas = new Canvas(bitmap);
    newCanvas.setDrawFilter(new PaintFlagsDrawFilter(0,
            Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    newCanvas.clipPath(path, Region.Op.INTERSECT);
    newCanvas.drawBitmap(mGradientLine, 0, 0, paint);
    return bitmap;
}
项目:BigApp_Discuz_Android    文件:EnergyCurveView.java   
/**
 * 创建裁剪的背景图片
 * 
 * @param paint
 * @param path
 * @param bitmap
 * @return
 */
private Bitmap creatBitmap(Paint paint, Path path, Bitmap bitmap) {
    Canvas newCanvas = new Canvas(bitmap);
    newCanvas.setDrawFilter(new PaintFlagsDrawFilter(0,
            Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    newCanvas.clipPath(path, Region.Op.INTERSECT);
    newCanvas.drawBitmap(mGradientLine, 0, 0, paint);
    return bitmap;
}
项目:BigApp_Discuz_Android    文件:BottomItemView.java   
private void drawSourceText(Canvas canvas, int alpha) {
    mTextPaint.setColor(mNormalColor);
    mTextPaint.setAlpha(255 - alpha);
    mTextPaint.setAntiAlias(true);
    int x = getMeasuredWidth() / 2 - mTextBound.width() / 2;
    int y = mIconLayoutRect.bottom + mIconMargin + mTextBound.height() + mText2IconHeight;

    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    canvas.drawText(mText, x, y - XIAODUI, mTextPaint);
}
项目:BigApp_Discuz_Android    文件:BottomItemView.java   
private void drawTargetText(Canvas canvas, int alpha) {
    mTextPaint.setColor(mSelectedColor);
    mTextPaint.setAlpha(alpha);
    mTextPaint.setAntiAlias(true);
    int x = getMeasuredWidth() / 2 - mTextBound.width() / 2;
    int y = mIconLayoutRect.bottom + mIconMargin + mTextBound.height() + mText2IconHeight;

    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    canvas.drawText(mText, x, y - XIAODUI, mTextPaint);
}
项目:BigApp_Discuz_Android    文件:BottomItemView.java   
private void drawSourceBitmap(Canvas canvas,int alpha) {
    mPaint.setColor(mNormalColor);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setAlpha(255);
    mCanvas.drawRect(mIconRect, mPaint);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    mPaint.setAlpha(255-alpha);

    mCanvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    mCanvas.drawBitmap(mIconBitmapNormal, mIconRect.left, mIconRect.top, mPaint);
    canvas.drawBitmap(mBitmap, 0, 0, null);
}
项目:collapselrecycler    文件:CircleImageView.java   
@Override
protected void onDraw(Canvas canvas) {
    if(getDrawable()==null){
        return;
    }
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    initBitmapShadow();
    canvas.drawCircle(radius, radius, radius - outCircleWidth, paint);
    canvas.drawCircle(radius, radius, radius - outCircleWidth*0.5F, outCirclePaint);
    canvas.drawCircle(radius, radius, radius-outCircleWidth - innerCircleWidth*0.5F, innerCirclePaint);
}
项目:GitPath    文件:WaveView.java   
public WaveView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.FILL);
    int textColor = context.obtainStyledAttributes(attrs, R.styleable.WaveViewStyle)
            .getColor(R.styleable.WaveViewStyle_wavecolor,0xFF009688);
    mPaint.setColor(textColor);
    mDrawFilter = new PaintFlagsDrawFilter(0,Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);
}
项目:TempControlView    文件:TempControlView.java   
private void init() {
    dialPaint = new Paint();
    dialPaint.setAntiAlias(true);
    dialPaint.setStrokeWidth(dp2px(2));
    dialPaint.setStyle(Paint.Style.STROKE);

    arcPaint = new Paint();
    arcPaint.setAntiAlias(true);
    arcPaint.setColor(Color.parseColor("#3CB7EA"));
    arcPaint.setStrokeWidth(dp2px(2));
    arcPaint.setStyle(Paint.Style.STROKE);

    titlePaint = new Paint();
    titlePaint.setAntiAlias(true);
    titlePaint.setTextSize(sp2px(15));
    titlePaint.setColor(Color.parseColor("#3B434E"));
    titlePaint.setStyle(Paint.Style.STROKE);

    tempFlagPaint = new Paint();
    tempFlagPaint.setAntiAlias(true);
    tempFlagPaint.setTextSize(sp2px(25));
    tempFlagPaint.setColor(Color.parseColor("#E4A07E"));
    tempFlagPaint.setStyle(Paint.Style.STROKE);

    buttonPaint = new Paint();
    tempFlagPaint.setAntiAlias(true);
    paintFlagsDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);

    tempPaint = new Paint();
    tempPaint.setAntiAlias(true);
    tempPaint.setTextSize(sp2px(60));
    tempPaint.setColor(Color.parseColor("#E27A3F"));
    tempPaint.setStyle(Paint.Style.STROKE);
}
项目:joy-app    文件:OsmDirectOverlay.java   
@Override
public void draw(Canvas arg0, MapView arg1, boolean arg2) {

    if (arg0.getDrawFilter() == null) {
        PaintFlagsDrawFilter drawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
        arg0.setDrawFilter(drawFilter);
    }
    super.draw(arg0, arg1, arg2);
}
项目:ZoomCropImage    文件:ZoomCropImageView.java   
/**
     * 剪切图片,返回剪切后的bitmap对象
     *
     * @return
     */
    public Bitmap crop(int outputWidth, int outputHeight) {
        int width = getWidth();
        int height = getHeight();
        int horizontalPadding = (width - mCropWidth) / 2;
        int verticalPadding = (height - mCropHeight) / 2;
        // TODO may cause OutOfMemory exception
        Bitmap bitmap = Bitmap.createBitmap(width, height,
                Bitmap.Config.ARGB_8888);
//      bitmap.setHasAlpha(true);
        Canvas canvas = new Canvas(bitmap);
        canvas.setDrawFilter(new PaintFlagsDrawFilter(0,
                Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG));
        Path clipPath = new Path();
        RectF rect = new RectF(horizontalPadding, verticalPadding, width
                - horizontalPadding, height - verticalPadding);
        switch (mCropShape) {
            case CropShape.SHAPE_RECTANGLE:
                clipPath.addRect(rect, Direction.CW);
                break;
            case CropShape.SHAPE_OVAL:
                clipPath.addOval(rect, Direction.CW);
                break;
        }
        canvas.clipPath(clipPath);

        draw(canvas);

        Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, horizontalPadding,
                verticalPadding, mCropWidth, mCropHeight);
        return Bitmap.createScaledBitmap(croppedBitmap, outputWidth, outputHeight,
                false);
    }
项目:SlidingCard    文件:SlidingCard.java   
@Override
protected void dispatchDraw(@NonNull Canvas canvas) {
    PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
            .FILTER_BITMAP_FLAG);
    canvas.setDrawFilter(pfd);
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child == null)
            return;
    }
    super.dispatchDraw(canvas);
}
项目:AndroidDemos    文件:MyImageView.java   
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isFirst) {
        isFirst = false;
        init();
    }
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG));
}