Java 类android.graphics.BlurMaskFilter.Blur 实例源码

项目:LaunchEnr    文件:ShadowGenerator.java   
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);
}
项目:LaunchEnr    文件:ShadowGenerator.java   
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;
    }
项目:buildAPKsSamples    文件:ShadowLayout.java   
/**
 * Called by the constructors - sets up the drawing parameters for the drop shadow.
 */
private void init() {
    mShadowPaint.setColor(Color.BLACK);
    mShadowPaint.setStyle(Style.FILL);
    setWillNotDraw(false);
    mShadowBitmap = Bitmap.createBitmap(sShadowRect.width(),
            sShadowRect.height(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(mShadowBitmap);
    mShadowPaint.setMaskFilter(new BlurMaskFilter(BLUR_RADIUS, Blur.NORMAL));
    c.translate(BLUR_RADIUS, BLUR_RADIUS);
    c.drawRoundRect(sShadowRectF, sShadowRectF.width() / 40,
            sShadowRectF.height() / 40, mShadowPaint);
}
项目:boohee_v5.6    文件:HightLightView.java   
private void init() {
    this.mPaint = new Paint();
    this.mPaint.setDither(true);
    this.mPaint.setAntiAlias(true);
    if (this.isBlur) {
        this.mPaint.setMaskFilter(new BlurMaskFilter(15.0f, Blur.SOLID));
    }
    this.mPaint.setStyle(Style.FILL);
    addViewForTip();
}
项目:FlickLauncher    文件:ShadowGenerator.java   
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);
}
项目:SimpleUILauncher    文件:ShadowGenerator.java   
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);
}
项目:Munin-for-Android    文件:Util.java   
public static Bitmap dropShadow(Bitmap src) {
    if (src == null)
        return null;

    try {
        // Parameters
        int verticalPadding = 10;
        int horizontalPadding = 10;
        int radius = 3;
        int color = 0x44000000;

        // Create result bitmap
        Bitmap bmOut = Bitmap.createBitmap(src.getWidth() + horizontalPadding, src.getHeight() + verticalPadding, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bmOut);
        canvas.drawColor(0, PorterDuff.Mode.CLEAR);
        Paint ptBlur = new Paint();
        ptBlur.setMaskFilter(new BlurMaskFilter(radius, Blur.OUTER));
        int[] offsetXY = new int[2];
        // Capture alpha into a bitmap
        Bitmap bmAlpha = src.extractAlpha(ptBlur, offsetXY);
        Paint ptAlphaColor = new Paint();
        ptAlphaColor.setColor(color);
        canvas.drawBitmap(bmAlpha, 0, 0, ptAlphaColor);
        bmAlpha.recycle();
        // Paint image source
        canvas.drawBitmap(src, radius, radius, null);
        return bmOut;
    } catch (Exception ex) {
        return src;
    }
}
项目:kora    文件:ColorDialog.java   
public TextSeekBarDrawable(Resources res, int id, boolean labelOnRight) {
    mText = res.getString(id);
    mProgress = res.getDrawable(android.R.drawable.progress_horizontal);
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setTypeface(Typeface.DEFAULT_BOLD);
    mPaint.setTextSize(16);
    mPaint.setColor(0xff000000);
    mOutlinePaint = new Paint(mPaint);
    mOutlinePaint.setStyle(Style.STROKE);
    mOutlinePaint.setStrokeWidth(3);
    mOutlinePaint.setColor(0xbbffc300);
    mOutlinePaint.setMaskFilter(new BlurMaskFilter(1, Blur.NORMAL));
    mTextWidth = mOutlinePaint.measureText(mText);
    mTextXScale = labelOnRight? 1 : 0;
    mAnimation = new ScrollAnimation();
}
项目:DevCamp2014    文件:ShadowLayout.java   
/**
 * Called by the constructors - sets up the drawing parameters for the drop shadow.
 */
private void init() {
    mShadowPaint.setColor(Color.BLACK);
    mShadowPaint.setStyle(Style.FILL);
    setWillNotDraw(false);
    mShadowBitmap = Bitmap.createBitmap(sShadowRect.width(),
            sShadowRect.height(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(mShadowBitmap);
    mShadowPaint.setMaskFilter(new BlurMaskFilter(BLUR_RADIUS, Blur.NORMAL));
    c.translate(BLUR_RADIUS, BLUR_RADIUS);
    c.drawRoundRect(sShadowRectF, sShadowRectF.width() / 40,
            sShadowRectF.height() / 40, mShadowPaint);
}
项目:Foto    文件:ShadowLayout.java   
/**
 * Called by the constructors - sets up the drawing parameters for the drop shadow.
 */
private void init() {
    mShadowPaint.setColor(Color.BLACK);
    mShadowPaint.setStyle(Style.FILL);
    setWillNotDraw(false);
    mShadowBitmap = Bitmap.createBitmap(sShadowRect.width(),
            sShadowRect.height(), Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(mShadowBitmap);
    mShadowPaint.setMaskFilter(new BlurMaskFilter(BLUR_RADIUS, Blur.NORMAL));
    c.translate(BLUR_RADIUS, BLUR_RADIUS);
    c.drawRoundRect(sShadowRectF, sShadowRectF.width() / 40,
            sShadowRectF.height() / 40, mShadowPaint);
}
项目:MPSolveForAndroid    文件:RootsRendererView.java   
/** 
 * @brief Prepare the Paints for later user in the onDraw() method.
 * 
 * Note that this method peform also some other basic initializations, such
 * as computing some sizes in a device-independent way and initializing
 * some String formatter. 
 * 
 *  As a rule of thumb, every expensive operation that does not need to
 *  be performed on every onDraw() call should be called here. 
 */
private void initPaints() {
    axisFormat = new DecimalFormat("#.#E0");

    // Compute a Device independent point size
    pointSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
            4, getResources().getDisplayMetrics());

    // ...and in the same spirit get a device independent width for the
    // ticks that we will draw on the axis. 
    tickWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
            3, getResources().getDisplayMetrics());

    // Paint used for the X and Y axis. 
    axisPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    axisPaint.setColor(
            getResources().getColor(R.color.rootsRendererView_axis));
    axisPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 
            12, getResources().getDisplayMetrics()));

    // Paint used for the points of the plot
    pointsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    pointsPaint.setColor(
            getResources().getColor(R.color.rootsRendererView_points));
    pointsPaint.setStyle(Style.FILL_AND_STROKE);
    pointsPaint.setMaskFilter(new BlurMaskFilter(2, Blur.INNER));

    // Paint similar to the above, but used for points marked
    // in the Approximation list. 
    markedPointsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    markedPointsPaint.setColor(
            getResources().getColor(R.color.rootsRendererView_MarkedPoints));
    markedPointsPaint.setStyle(Style.FILL_AND_STROKE);
    markedPointsPaint.setMaskFilter(new BlurMaskFilter (2, Blur.INNER));
}
项目:android-couchpotato    文件:ShadowLayout.java   
/**
 * Called by the constructors - sets up the drawing parameters for the drop shadow.
 */
private void init() {
  mShadowPaint.setColor(Color.BLACK);
  mShadowPaint.setStyle(Style.FILL);
  setWillNotDraw(false);
  mShadowBitmap =
      Bitmap.createBitmap(sShadowRect.width(), sShadowRect.height(), Bitmap.Config.ARGB_8888);
  Canvas c = new Canvas(mShadowBitmap);
  mShadowPaint.setMaskFilter(new BlurMaskFilter(BLUR_RADIUS, Blur.NORMAL));
  c.translate(BLUR_RADIUS, BLUR_RADIUS);
  c.drawRoundRect(sShadowRectF, sShadowRectF.width() / 40, sShadowRectF.height() / 40,
      mShadowPaint);
}
项目:OmniSnitch    文件:BitmapFilter.java   
/**
 * Returns a glowed image of the provided icon. If the
 * provided name is already in the cache, the cached image
 * will be returned. Otherwise, the bitmap will be glowed and
 * cached under the provided name
 *
 * @param name The name of the bitmap - if name == null dont cache
 * @param src  The bitmap of the icon itself
 * @return Glowed bitmap
 */
public Bitmap getGlow(String name, int glowColor, Bitmap src) {
    if (name != null && mGlowCache.containsKey(name)) {
        return mGlowCache.get(name);
    } else {
        // An added margin to the initial image
        int margin = 0;
        int halfMargin = margin / 2;

        // The glow radius
        int glowRadius = 12;

        // Extract the alpha from the source image
        Bitmap alpha = src.extractAlpha();

        // The output bitmap (with the icon + glow)
        Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,
                src.getHeight() + margin, Bitmap.Config.ARGB_8888);

        // The canvas to paint on the image
        Canvas canvas = new Canvas(bmp);

        Paint paint = new Paint();
        paint.setColor(glowColor);

        // Outer glow
        ColorFilter emphasize = new LightingColorFilter(glowColor, 1);
        paint.setColorFilter(emphasize);
        canvas.drawBitmap(src, halfMargin, halfMargin, paint);
        paint.setColorFilter(null);
        paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER));
        canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);

        if(name!=null){
            // Cache icon
            mGlowCache.put(name, bmp);
        }

        return bmp;
    }
}