Search in sources :

Example 16 with BlurMaskFilter

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

the class HighlightView method setup.

/**
	 * Setup.
	 * 
	 * @param m
	 *           the m
	 * @param imageRect
	 *           the image rect
	 * @param cropRect
	 *           the crop rect
	 * @param maintainAspectRatio
	 *           the maintain aspect ratio
	 */
public void setup(Matrix m, Rect imageRect, RectF cropRect, boolean maintainAspectRatio) {
    mMatrix = new Matrix(m);
    mCropRect = cropRect;
    mImageRect = new RectF(imageRect);
    mMaintainAspectRatio = maintainAspectRatio;
    double ratio = (double) mCropRect.width() / (double) mCropRect.height();
    mInitialAspectRatio = Math.round(ratio * 1000.0) / 1000.0;
    // Log.i( LOG_TAG, "aspect ratio: " + mInitialAspectRatio );
    computeLayout(true, mDrawRect);
    mOutlinePaint.setStrokeWidth(stroke_width);
    mOutlinePaint.setStyle(Paint.Style.STROKE);
    mOutlinePaint.setAntiAlias(false);
    try {
        ReflectionUtils.invokeMethod(mOutlinePaint, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mOutlinePaint2.setStrokeWidth(internal_stroke_width);
    mOutlinePaint2.setStyle(Paint.Style.STROKE);
    mOutlinePaint2.setAntiAlias(false);
    mOutlinePaint2.setColor(highlight_internal_color);
    try {
        ReflectionUtils.invokeMethod(mOutlinePaint2, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mOutlineFill.setColor(highlight_outside_color);
    mOutlineFill.setStyle(Paint.Style.FILL);
    mOutlineFill.setAntiAlias(false);
    try {
        ReflectionUtils.invokeMethod(mOutlineFill, "setHinting", new Class<?>[] { int.class }, 0);
    } catch (ReflectionException e) {
    }
    mLinesPaintShadow.setStrokeWidth(internal_stroke_width);
    mLinesPaintShadow.setAntiAlias(true);
    mLinesPaintShadow.setColor(Color.BLACK);
    mLinesPaintShadow.setStyle(Paint.Style.STROKE);
    mLinesPaintShadow.setMaskFilter(new BlurMaskFilter(2, Blur.NORMAL));
    setMode(Mode.None);
    init();
}
Also used : RectF(android.graphics.RectF) ReflectionException(com.aviary.android.feather.library.utils.ReflectionUtils.ReflectionException) Matrix(android.graphics.Matrix) BlurMaskFilter(android.graphics.BlurMaskFilter)

Example 17 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project android_packages_apps_Launcher2 by CyanogenMod.

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(R.dimen.app_icon_size);
    sIconTextureWidth = sIconTextureHeight = sIconWidth;
    sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
    sGlowColorPressedPaint.setColor(0xffffc300);
    sGlowColorFocusedPaint.setColor(0xffff8e00);
    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 18 with BlurMaskFilter

use of android.graphics.BlurMaskFilter in project android_packages_apps_Launcher2 by CyanogenMod.

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 = sExtraThickOuterBlurMaskFilter;
            break;
        case THICK:
            outerBlurMaskFilter = sThickOuterBlurMaskFilter;
            break;
        case MEDIUM:
            outerBlurMaskFilter = sMediumOuterBlurMaskFilter;
            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(sMediumOuterBlurMaskFilter);
    } else {
        mBlurPaint.setMaskFilter(sThinOuterBlurMaskFilter);
    }
    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 = sExtraThickInnerBlurMaskFilter;
            break;
        case THICK:
            innerBlurMaskFilter = sThickInnerBlurMaskFilter;
            break;
        case MEDIUM:
            innerBlurMaskFilter = sMediumInnerBlurMaskFilter;
            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)

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