Search in sources :

Example 6 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project mobile-android by photo.

the class AdjustImageView method initImageView.

/**
	 * Inits the image view.
	 */
private void initImageView() {
    mMatrix = new Matrix();
    mScaleType = ScaleType.FIT_CENTER;
    Context context = getContext();
    int highlight_color = context.getResources().getColor(R.color.feather_rotate_highlight_stroke_color);
    int highlight_stroke_internal_color = context.getResources().getColor(R.color.feather_rotate_highlight_grid_stroke_color);
    int highlight_stroke_internal_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_grid_stroke_width);
    int highlight_outside_color = context.getResources().getColor(R.color.feather_rotate_highlight_outside);
    int highlight_stroke_width = context.getResources().getInteger(R.integer.feather_rotate_highlight_stroke_width);
    mOutlinePaint.setStrokeWidth(highlight_stroke_width);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(true);
    mOutlinePaint.setColor(highlight_color);
    mOutlineFill.setStyle(Paint.Style.FILL);
    mOutlineFill.setAntiAlias(false);
    mOutlineFill.setColor(highlight_outside_color);
    mOutlineFill.setDither(false);
    try {
        ReflectionUtils.invokeMethod(mOutlineFill, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaint.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaint.setAntiAlias(false);
    mLinesPaint.setDither(false);
    mLinesPaint.setStyle(Paint.Style.STROKE);
    mLinesPaint.setColor(highlight_stroke_internal_color);
    try {
        ReflectionUtils.invokeMethod(mLinesPaint, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaintShadow.setStrokeWidth(highlight_stroke_internal_width);
    mLinesPaintShadow.setAntiAlias(true);
    mLinesPaintShadow.setColor(Color.BLACK);
    mLinesPaintShadow.setStyle(Paint.Style.STROKE);
    mLinesPaintShadow.setMaskFilter(new BlurMaskFilter(2, Blur.NORMAL));
    mOutlineFillAlpha = mOutlineFill.getAlpha();
    mOutlinePaintAlpha = mOutlinePaint.getAlpha();
    mLinesAlpha = mLinesPaint.getAlpha();
    mLinesShadowAlpha = mLinesPaintShadow.getAlpha();
    mOutlinePaint.setAlpha(0);
    mOutlineFill.setAlpha(0);
    mLinesPaint.setAlpha(0);
    mLinesPaintShadow.setAlpha(0);
    android.content.res.Resources resources = getContext().getResources();
    mStraightenDrawable = resources.getDrawable(R.drawable.feather_straighten_knob);
    double w = mStraightenDrawable.getIntrinsicWidth();
    double h = mStraightenDrawable.getIntrinsicHeight();
    handleWidth = (int) Math.ceil(w / 2.0);
    handleHeight = (int) Math.ceil(h / 2.0);
}
Also used : Context(android.content.Context) ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) Matrix(android.graphics.Matrix) BlurMaskFilter(android.graphics.BlurMaskFilter) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) Resources(android.content.res.Resources)

Example 7 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project ADWLauncher2 by boombuler.

the class Utilities method initStatics.

private static void initStatics(Context context) {
    final Resources resources = context.getResources();
    final DisplayMetrics metrics = resources.getDisplayMetrics();
    final float density = metrics.density;
    sIconWidth = sIconHeight = (int) resources.getDimension(android.R.dimen.app_icon_size);
    sIconTextureWidth = sIconTextureHeight = sIconWidth + 2;
    sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
    sGlowColorPressedPaint.setColor(0xffffc300);
    //TODO: sGlowColorPressedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
    sGlowColorFocusedPaint.setColor(0xffff8e00);
    //TODO: sGlowColorFocusedPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30));
    ColorMatrix cm = new ColorMatrix();
    cm.setSaturation(0.2f);
    sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
    sDisabledPaint.setAlpha(0x88);
}
Also used : ColorMatrixColorFilter(android.graphics.ColorMatrixColorFilter) ColorMatrix(android.graphics.ColorMatrix) BlurMaskFilter(android.graphics.BlurMaskFilter) Resources(android.content.res.Resources) DisplayMetrics(android.util.DisplayMetrics)

Example 8 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project wire-android by wireapp.

the class CircularSeekBar method initPaints.

/**
     * Initializes the {@code Paint} objects with the appropriate styles.
     */
protected void initPaints() {
    circlePaint = new Paint();
    circlePaint.setAntiAlias(true);
    circlePaint.setDither(true);
    circlePaint.setColor(circleColor);
    circlePaint.setStrokeWidth(circleStrokeWidth);
    circlePaint.setStyle(Paint.Style.STROKE);
    circlePaint.setStrokeJoin(Paint.Join.ROUND);
    circlePaint.setStrokeCap(Paint.Cap.ROUND);
    circleFillPaint = new Paint();
    circleFillPaint.setAntiAlias(true);
    circleFillPaint.setDither(true);
    circleFillPaint.setColor(circleFillColor);
    circleFillPaint.setStyle(Paint.Style.FILL);
    circleProgressPaint = new Paint();
    circleProgressPaint.setAntiAlias(true);
    circleProgressPaint.setDither(true);
    circleProgressPaint.setColor(circleProgressColor);
    circleProgressPaint.setStrokeWidth(circleStrokeWidth);
    circleProgressPaint.setStyle(Paint.Style.STROKE);
    circleProgressGlowPaint = new Paint();
    circleProgressGlowPaint.set(circleProgressPaint);
    if (!isInEditMode()) {
        circleProgressGlowPaint.setMaskFilter(new BlurMaskFilter((5f * dpToPxScale), BlurMaskFilter.Blur.NORMAL));
    }
    pointerPaint = new Paint();
    pointerPaint.setAntiAlias(true);
    pointerPaint.setDither(true);
    pointerPaint.setStyle(Paint.Style.FILL);
    pointerPaint.setColor(pointerColor);
    pointerPaint.setStrokeWidth(pointerRadius);
    pointerHaloPaint = new Paint();
    pointerHaloPaint.set(pointerPaint);
    pointerHaloPaint.setColor(pointerHaloColor);
    pointerHaloPaint.setAlpha(pointerAlpha);
    pointerHaloPaint.setStrokeWidth(pointerRadius + pointerHaloWidth);
    pointerHaloBorderPaint = new Paint();
    pointerHaloBorderPaint.set(pointerPaint);
    pointerHaloBorderPaint.setStrokeWidth(pointerHaloBorderWidth);
    pointerHaloBorderPaint.setStyle(Paint.Style.STROKE);
}
Also used : BlurMaskFilter(android.graphics.BlurMaskFilter) Paint(android.graphics.Paint)

Example 9 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project Launcher3 by chislon.

the class HolographicOutlineHelper method applyExpensiveOutlineWithBlur.

void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas, int color, int outlineColor, boolean clipAlpha, int thickness) {
    // other types of partial transparency when defining the shape of the object
    if (clipAlpha) {
        int[] srcBuffer = new int[srcDst.getWidth() * srcDst.getHeight()];
        srcDst.getPixels(srcBuffer, 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
        for (int i = 0; i < srcBuffer.length; i++) {
            final int alpha = srcBuffer[i] >>> 24;
            if (alpha < 188) {
                srcBuffer[i] = 0;
            }
        }
        srcDst.setPixels(srcBuffer, 0, srcDst.getWidth(), 0, 0, srcDst.getWidth(), srcDst.getHeight());
    }
    Bitmap glowShape = srcDst.extractAlpha();
    // calculate the outer blur first
    BlurMaskFilter outerBlurMaskFilter;
    switch(thickness) {
        case EXTRA_THICK:
            outerBlurMaskFilter = mExtraThickOuterBlurMaskFilter;
            break;
        case THICK:
            outerBlurMaskFilter = mThickOuterBlurMaskFilter;
            break;
        case MEDIUM:
            outerBlurMaskFilter = mMediumOuterBlurMaskFilter;
            break;
        default:
            throw new RuntimeException("Invalid blur thickness");
    }
    mBlurPaint.setMaskFilter(outerBlurMaskFilter);
    int[] outerBlurOffset = new int[2];
    Bitmap thickOuterBlur = glowShape.extractAlpha(mBlurPaint, outerBlurOffset);
    if (thickness == EXTRA_THICK) {
        mBlurPaint.setMaskFilter(mMediumOuterBlurMaskFilter);
    } else {
        mBlurPaint.setMaskFilter(mThinOuterBlurMaskFilter);
    }
    int[] brightOutlineOffset = new int[2];
    Bitmap brightOutline = glowShape.extractAlpha(mBlurPaint, brightOutlineOffset);
    // calculate the inner blur
    srcDstCanvas.setBitmap(glowShape);
    srcDstCanvas.drawColor(0xFF000000, PorterDuff.Mode.SRC_OUT);
    BlurMaskFilter innerBlurMaskFilter;
    switch(thickness) {
        case EXTRA_THICK:
            innerBlurMaskFilter = mExtraThickInnerBlurMaskFilter;
            break;
        case THICK:
            innerBlurMaskFilter = mThickInnerBlurMaskFilter;
            break;
        case MEDIUM:
            innerBlurMaskFilter = mMediumInnerBlurMaskFilter;
            break;
        default:
            throw new RuntimeException("Invalid blur thickness");
    }
    mBlurPaint.setMaskFilter(innerBlurMaskFilter);
    int[] thickInnerBlurOffset = new int[2];
    Bitmap thickInnerBlur = glowShape.extractAlpha(mBlurPaint, thickInnerBlurOffset);
    // mask out the inner blur
    srcDstCanvas.setBitmap(thickInnerBlur);
    srcDstCanvas.drawBitmap(glowShape, -thickInnerBlurOffset[0], -thickInnerBlurOffset[1], mErasePaint);
    srcDstCanvas.drawRect(0, 0, -thickInnerBlurOffset[0], thickInnerBlur.getHeight(), mErasePaint);
    srcDstCanvas.drawRect(0, 0, thickInnerBlur.getWidth(), -thickInnerBlurOffset[1], mErasePaint);
    // draw the inner and outer blur
    srcDstCanvas.setBitmap(srcDst);
    srcDstCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    mHolographicPaint.setColor(color);
    srcDstCanvas.drawBitmap(thickInnerBlur, thickInnerBlurOffset[0], thickInnerBlurOffset[1], mHolographicPaint);
    srcDstCanvas.drawBitmap(thickOuterBlur, outerBlurOffset[0], outerBlurOffset[1], mHolographicPaint);
    // draw the bright outline
    mHolographicPaint.setColor(outlineColor);
    srcDstCanvas.drawBitmap(brightOutline, brightOutlineOffset[0], brightOutlineOffset[1], mHolographicPaint);
    // cleanup
    srcDstCanvas.setBitmap(null);
    brightOutline.recycle();
    thickOuterBlur.recycle();
    thickInnerBlur.recycle();
    glowShape.recycle();
}
Also used : Bitmap(android.graphics.Bitmap) BlurMaskFilter(android.graphics.BlurMaskFilter) Paint(android.graphics.Paint)

Example 10 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project Highlight by hongyangAndroid.

the class MainActivity method showNextKnownTipView.

/**
     * 显示 next模式 我知道了提示高亮布局
     * @param view id为R.id.iv_known的控件
     * @author isanwenyu@163.com
     */
public void showNextKnownTipView(View view) {
    mHightLight = //
    new HighLight(MainActivity.this).autoRemove(//设置背景点击高亮布局自动移除为false 默认为true
    false).intercept(//拦截属性默认为true 使下方callback生效
    true).enableNext().anchor(//如果是Activity上增加引导层,不需要设置anchor
    findViewById(R.id.id_container)).addHighLight(R.id.btn_rightLight, R.layout.info_known, new OnLeftPosCallback(45), new RectLightShape()).addHighLight(R.id.btn_light, R.layout.info_known, new OnRightPosCallback(5), new BaseLightShape(5, 5) {

        @Override
        protected void resetRectF4Shape(RectF viewPosInfoRectF, float dx, float dy) {
            //缩小高亮控件范围
            viewPosInfoRectF.inset(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dx, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dy, getResources().getDisplayMetrics()));
        }

        @Override
        protected void drawShape(Bitmap bitmap, HighLight.ViewPosInfo viewPosInfo) {
            //custom your hight light shape 自定义高亮形状
            Canvas canvas = new Canvas(bitmap);
            Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
            paint.setDither(true);
            paint.setAntiAlias(true);
            paint.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.SOLID));
            RectF rectF = viewPosInfo.rectF;
            canvas.drawOval(rectF, paint);
        }
    }).addHighLight(R.id.btn_bottomLight, R.layout.info_known, new OnTopPosCallback(), new CircleLightShape()).addHighLight(view, R.layout.info_known, new OnBottomPosCallback(10), new RectLightShape()).setOnRemoveCallback(new //监听移除回调 intercept为true时生效
    HighLightInterface.OnRemoveCallback() {

        @Override
        public void onRemove() {
            Toast.makeText(MainActivity.this, "The HightLight view has been removed", Toast.LENGTH_SHORT).show();
        }
    }).setOnShowCallback(new //监听显示回调 intercept为true时生效
    HighLightInterface.OnShowCallback() {

        @Override
        public void onShow() {
            Toast.makeText(MainActivity.this, "The HightLight view has been shown", Toast.LENGTH_SHORT).show();
        }
    });
    mHightLight.show();
}
Also used : HighLight(zhy.com.highlight.HighLight) OnLeftPosCallback(zhy.com.highlight.position.OnLeftPosCallback) Canvas(android.graphics.Canvas) CircleLightShape(zhy.com.highlight.shape.CircleLightShape) HighLightInterface(zhy.com.highlight.interfaces.HighLightInterface) RectLightShape(zhy.com.highlight.shape.RectLightShape) Paint(android.graphics.Paint) BaseLightShape(zhy.com.highlight.shape.BaseLightShape) OnRightPosCallback(zhy.com.highlight.position.OnRightPosCallback) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) BlurMaskFilter(android.graphics.BlurMaskFilter) OnTopPosCallback(zhy.com.highlight.position.OnTopPosCallback) OnBottomPosCallback(zhy.com.highlight.position.OnBottomPosCallback)

Aggregations

BlurMaskFilter (android.graphics.BlurMaskFilter)18 Paint (android.graphics.Paint)13 Resources (android.content.res.Resources)6 Bitmap (android.graphics.Bitmap)4 ColorMatrix (android.graphics.ColorMatrix)4 ColorMatrixColorFilter (android.graphics.ColorMatrixColorFilter)4 DisplayMetrics (android.util.DisplayMetrics)4 Canvas (android.graphics.Canvas)3 Matrix (android.graphics.Matrix)3 RectF (android.graphics.RectF)3 ReflectionException (com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException)3 Context (android.content.Context)2 SuppressLint (android.annotation.SuppressLint)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 GeoPointImpl (carnero.cgeo.mapinterfaces.GeoPointImpl)1 AdapterView (com.aviary.android.feather.widget.AdapterView)1 OnItemsScrollListener (com.aviary.android.feather.widget.Gallery.OnItemsScrollListener)1 ImageViewTouchAndDraw (com.aviary.android.feather.widget.ImageViewTouchAndDraw)1