android.graphics.PaintFlagsDrawFilter Java Examples

The following examples show how to use android.graphics.PaintFlagsDrawFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CircleImageView.java    From Dainty with Apache License 2.0 6 votes vote down vote up
private void init(Context context) {
//        Paint paint = new Paint();
//        // 透明度: 00%=FF(不透明) 100%=00(透明)
//        paint.setColor(Color.WHITE);
//        paint.setStyle(Paint.Style.STROKE);
//        // 解决图片拉伸后出现锯齿的两种办法: 1.画笔上设置抗锯齿 2.画布上设置抗锯齿
//        // http://labs.easymobi.cn/?p=3819
//        paint.setFlags(Paint.ANTI_ALIAS_FLAG);
//        paint.setAntiAlias(true);    //设置线条等图形的抗锯齿
        int clearBits = 0;
        int setBits = Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG;
        pfdf = new PaintFlagsDrawFilter(clearBits, setBits);
        //由于imageview有默认底色,如黑色,设置背景为透明是为了第一次setImageBitmap时不显示圆以外方型的默认背景色
        //但是这样在中兴nubia手机上还会首先显示正方形黑色背景,然后才变圆(解决办法,先裁成圆再setImageBitmap)
        setBackgroundColor(context.getResources().getColor(android.R.color.transparent));
    }
 
Example #2
Source File: SunLineView.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #3
Source File: RoundImageView.java    From CardSwipeLayout with MIT License 6 votes vote down vote up
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);
}
 
Example #4
Source File: CircleProgressView.java    From CircleProgressView with MIT License 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    // TODO: 2017/7/8  padding
    canvas.translate(mProgressHeadRadius * 2, mProgressHeadRadius * 2);
    // TODO: 2017/7/8  画进度条
    draProgressArc(canvas);
    // TODO: 2017/7/8  移坐标到圆心
    canvas.translate(arcRadius, arcRadius);
    // TODO: 2017/7/8  计算圆心半径到圆周上的某个点坐标
    Coordinate coordinate = center2Point(angle - 90, arcRadius);
    float cx = coordinate.x; //绘制原点起始坐标x
    float cy = coordinate.y;
    // TODO: 2017/7/8 绘制 小圆点
    draHead(canvas, cx, cy);
    // TODO: 2017/7/8 绘制 小圆点上的文字
    draHeadText(canvas, cx, cy);
}
 
Example #5
Source File: ViewfinderView.java    From letv with Apache License 2.0 6 votes vote down vote up
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);
    }
}
 
Example #6
Source File: BuildLayerFrameLayout.java    From Cybernet-VPN with GNU General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #7
Source File: CircleImageView.java    From AndroidDemo with MIT License 6 votes vote down vote up
private void init() {
//        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
//        Xfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
//        paint.setXfermode(xfermode);
//        paint.setStrokeWidth(50);
//        paint.setColor(0x000000);

        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(0xFF303F9F);
        paint.setStrokeWidth(50);

        path = new Path();
        paintFlagsDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
//        setLayerType(View.LAYER_TYPE_HARDWARE, null);

    }
 
Example #8
Source File: SunLineView.java    From stynico with MIT License 6 votes vote down vote up
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();
}
 
Example #9
Source File: ArcView.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(mBgColor);
    mPaint.setAntiAlias(true);//抗锯齿

    Rect rect = new Rect(0, 0, mWidth, mHeight - mArcHeight);
    canvas.drawRect(rect, mPaint);
    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));

    Path path = new Path();
    path.moveTo(0, mHeight - mArcHeight);
    path.quadTo(mWidth / 2, mHeight, mWidth, mHeight - mArcHeight);
    canvas.drawPath(path, mPaint);

}
 
Example #10
Source File: BottomItemView.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
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);

    }
 
Example #11
Source File: FloatingActionButton.java    From MaterialButton with MIT License 6 votes vote down vote up
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);
}
 
Example #12
Source File: SunLineView.java    From styT with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #13
Source File: SunLineView.java    From BitkyShop with MIT License 6 votes vote down vote up
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();
}
 
Example #14
Source File: ClearEditText.java    From AndroidUI with MIT License 6 votes vote down vote up
@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();
    }
}
 
Example #15
Source File: WaveView.java    From youqu_master with Apache License 2.0 6 votes vote down vote up
public WaveView(Context context, AttributeSet attrs) {
    super(context, attrs);
    //初始化路径
    mAbovePath = new Path();
    mBelowWavePath = new Path();
    //初始化画笔
    mAboveWavePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mAboveWavePaint.setAntiAlias(true);
    mAboveWavePaint.setStyle(Paint.Style.FILL);
    mAboveWavePaint.setColor(Color.WHITE);

    mBelowWavePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBelowWavePaint.setAntiAlias(true);
    mBelowWavePaint.setStyle(Paint.Style.FILL);
    mBelowWavePaint.setColor(Color.WHITE);
    mBelowWavePaint.setAlpha(80);
    //画布抗锯齿
    mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
 
Example #16
Source File: SunLineView.java    From styT with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #17
Source File: FlatButton.java    From MaterialButton with MIT License 6 votes vote down vote up
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);
}
 
Example #18
Source File: BuildLayerFrameLayout.java    From FlowingPager with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #19
Source File: ActivityPicker.java    From JotaTextEditor with Apache License 2.0 5 votes vote down vote up
public IconResizer(int width, int height, DisplayMetrics metrics) {
    mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
            Paint.FILTER_BITMAP_FLAG));

    mMetrics = metrics;
    mIconWidth = width;
    mIconHeight = height;
}
 
Example #20
Source File: KLineView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 创建裁剪的背景图片
 * 
 * @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;
}
 
Example #21
Source File: EnergyCurveView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
/**
 * 创建裁剪的背景图片
 * 
 * @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;
}
 
Example #22
Source File: BottomItemView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #23
Source File: BottomItemView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #24
Source File: TabMainView.java    From FoldingTabBar.Android with MIT License 5 votes vote down vote up
private void initPaint() {
	colors[0] = getResources().getColor(R.color.tabbar_main);
	colors[1] = getResources().getColor(R.color.tabbar_secondly);
	colors[2] = getResources().getColor(R.color.background_color);
	paint = new Paint();
	paint.setColor(colors[0]);
	paint.setAntiAlias(true);
	paint.setStyle(Paint.Style.FILL);
	paintFlagsDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
}
 
Example #25
Source File: BottomItemView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #26
Source File: IconUtilities.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public IconUtilities(Context context) {
    final Resources resources = context.getResources();
    DisplayMetrics metrics = mDisplayMetrics = resources.getDisplayMetrics();
    final float density = metrics.density;
    final float blurPx = 5 * density;

    mIconWidth = mIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);
    mIconTextureWidth = mIconTextureHeight = mIconWidth + (int)(blurPx*2);
    mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
            Paint.FILTER_BITMAP_FLAG));
}
 
Example #27
Source File: TempControlView.java    From TempControlView with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #28
Source File: BrushDrawable.java    From libcommon with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #29
Source File: RotateTextImageView.java    From Social with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化Paint
 */
protected void initCanvasInfo() {
    pfdf = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
            | Paint.FILTER_BITMAP_FLAG);
    paint = new Paint();
    paint.setAntiAlias(true);
    matrix = new Matrix();
    matrix.setRotate(5);
}
 
Example #30
Source File: AvatarRectView.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected final void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
    mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);//
    this.mRect.left = ((getWidth() - this.mAvatarSize) / 2);
    this.mRect.right = ((getWidth() + this.mAvatarSize) / 2);
    this.mRect.top = ((getHeight() - this.mAvatarSize) / 2);
    this.mRect.bottom = ((getHeight() + this.mAvatarSize) / 2);

    rectArray[0].set(0, 0, mRect.left, mRect.top);
    rectArray[1].set(mRect.left, 0, mRect.right, this.mRect.top);
    rectArray[2].set(this.mRect.right, 0, getWidth(), this.mRect.top);
    rectArray[3].set(0, mRect.top, mRect.left, this.mRect.bottom);
    rectArray[4].set(mRect.right, mRect.top, getWidth(), this.mRect.bottom);
    rectArray[5].set(0, mRect.bottom, this.mRect.left, getHeight());
    rectArray[6].set(mRect.left, mRect.bottom, this.mRect.right, getHeight());
    rectArray[7].set(mRect.right, mRect.bottom, getWidth(), getHeight());

    this.mPaint.setColor(0x7f000000);
    this.mPaint.setStyle(Paint.Style.FILL);
    for (Rect rect : rectArray) {
        canvas.drawRect(rect, this.mPaint);
    }

    mPaint.reset();
    if (!centerBitmap.isRecycled()) {
        canvas.drawBitmap(centerBitmap, centerRect, mRect, mPaint);
    } else {
        Log.i(TAG, "bitmap recycle");
    }
    //centerBitmap.recycle();

}