android.graphics.BlurMaskFilter Java Examples
The following examples show how to use
android.graphics.BlurMaskFilter.
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: HolographicOutlineHelper.java From Trebuchet with GNU General Public License v3.0 | 6 votes |
private HolographicOutlineHelper(Context context) { Resources res = context.getResources(); float mediumBlur = res.getDimension(R.dimen.blur_size_medium_outline); mMediumOuterBlurMaskFilter = new BlurMaskFilter(mediumBlur, BlurMaskFilter.Blur.OUTER); mMediumInnerBlurMaskFilter = new BlurMaskFilter(mediumBlur, BlurMaskFilter.Blur.NORMAL); mThinOuterBlurMaskFilter = new BlurMaskFilter( res.getDimension(R.dimen.blur_size_thin_outline), BlurMaskFilter.Blur.OUTER); mShadowBlurMaskFilter = new BlurMaskFilter( res.getDimension(R.dimen.blur_size_click_shadow), BlurMaskFilter.Blur.NORMAL); mDrawPaint.setFilterBitmap(true); mDrawPaint.setAntiAlias(true); mBlurPaint.setFilterBitmap(true); mBlurPaint.setAntiAlias(true); mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mErasePaint.setFilterBitmap(true); mErasePaint.setAntiAlias(true); }
Example #2
Source File: HolographicOutlineHelper.java From LB-Launcher with Apache License 2.0 | 6 votes |
private HolographicOutlineHelper(Context context) { final float scale = LauncherAppState.getInstance().getScreenDensity(); mMediumOuterBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.OUTER); mThinOuterBlurMaskFilter = new BlurMaskFilter(scale * 1.0f, BlurMaskFilter.Blur.OUTER); mMediumInnerBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.NORMAL); mShaowBlurMaskFilter = new BlurMaskFilter(scale * 4.0f, BlurMaskFilter.Blur.NORMAL); mShadowOffset = (int) (scale * 2.0f); shadowBitmapPadding = (int) (scale * 4.0f); mDrawPaint.setFilterBitmap(true); mDrawPaint.setAntiAlias(true); mBlurPaint.setFilterBitmap(true); mBlurPaint.setAntiAlias(true); mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mErasePaint.setFilterBitmap(true); mErasePaint.setAntiAlias(true); }
Example #3
Source File: FreeHandView.java From Machine-Learning-Projects-for-Mobile-Applications with MIT License | 6 votes |
public FreeHandView(Context context, AttributeSet attrs) { super(context, attrs); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setColor(DEFAULT_COLOR); //mPaint.setAlpha(DEFAULT_COLOR); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeCap(Paint.Cap.ROUND); mPaint.setXfermode(null); mPaint.setAlpha(0xff); mEmboss = new EmbossMaskFilter(new float[] {1, 1, 1}, 0.4f, 6, 3.5f); mBlur = new BlurMaskFilter(5, BlurMaskFilter.Blur.NORMAL); }
Example #4
Source File: BitmapUtils.java From Android-Next with Apache License 2.0 | 6 votes |
/** * 为指定图片增加阴影 * * @param map 图片 * @param radius 阴影的半径 * @return */ public static Bitmap drawShadow(Bitmap map, int radius) { if (map == null) return null; BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER); Paint shadowPaint = new Paint(); shadowPaint.setMaskFilter(blurFilter); int[] offsetXY = new int[2]; Bitmap shadowImage = map.extractAlpha(shadowPaint, offsetXY); shadowImage = shadowImage.copy(Config.ARGB_8888, true); Canvas c = new Canvas(shadowImage); c.drawBitmap(map, -offsetXY[0], -offsetXY[1], null); return shadowImage; }
Example #5
Source File: OkulusDrawable.java From okulus with Apache License 2.0 | 6 votes |
@Override protected void onBoundsChange(Rect bounds) { super.onBoundsChange(bounds); mRect.set(bounds); mShadowRect.set(mRect); mShadowRect.inset(mShadowSize, mShadowSize); if (mFullCircle) { mCornerRadius = Math.abs(mRect.left - mRect.right) / 2; } if (mBorderSize > 0) { initRectsWithBorders(); } else { initRectsWithoutBorders(); } if(mShadowSize > 0) { mShadowMaskFilter = new BlurMaskFilter(mShadowSize * 0.95F, BlurMaskFilter.Blur.SOLID); } updateShaderMatrix(); }
Example #6
Source File: RippleAnimator.java From TheGlowingLoader with Apache License 2.0 | 6 votes |
public void draw(Canvas canvas, Paint paint) { paint.setMaskFilter(null); paint.setStyle(Paint.Style.STROKE); paint.setColor(configuration.getRippleColor()); paint.setStrokeWidth(circleStroke); paint.setAlpha((int) (255 * circleAlpha)); canvas.drawCircle(cX, cY, circleRadius, paint); if (!configuration.isDisableShadows()) { paint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.NORMAL)); paint.setStrokeWidth(.28f * circleRadius); paint.setAlpha((int) (255 * circleAlpha * configuration.getShadowOpacity())); canvas.drawCircle(cX, cY + 100, circleRadius, paint); } paint.setMaskFilter(null); paint.setColor(configuration.getRippleColor()); paint.setStrokeWidth(circleStroke2); paint.setAlpha((int) (255 * circleAlpha2)); canvas.drawCircle(cX, cY, circleRadius2, paint); }
Example #7
Source File: BlurMaskFilterActivity.java From android-graphics-demo with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_blur_mask_filter); LinearLayout container = (LinearLayout) findViewById(R.id.container); for (BlurMaskFilter.Blur style : BlurMaskFilter.Blur.values()) { TextView textView = new TextView(this); textView.setTextAppearance(this, R.style.TextAppearance_Huge_Green); applyFilter(textView, style); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; container.addView(textView, params); } }
Example #8
Source File: FloatParticle.java From kAndroid with Apache License 2.0 | 6 votes |
public FloatParticle(int width, int height) { mWidth = width; mHeight = height; mRandom = new Random(); startPoint = new Point((int) (mRandom.nextFloat() * mWidth), (int) (mRandom.nextFloat() * mHeight)); // 抗锯齿 mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setColor(Color.WHITE); // 防抖动 mPaint.setDither(true); mPaint.setStyle(Paint.Style.FILL); // 设置模糊效果 边缘模糊 mPaint.setMaskFilter(new BlurMaskFilter(BLUR_SIZE, BlurMaskFilter.Blur.SOLID)); mPath = new Path(); mPathMeasure = new PathMeasure(); startPoint.x = (int) (mRandom.nextFloat() * mWidth); startPoint.y = (int) (mRandom.nextFloat() * mHeight); }
Example #9
Source File: KcaViewButtonService.java From kcanotify_h5-master with GNU General Public License v3.0 | 6 votes |
private void setFairyImage() { boolean glow_available = fairy_glow_on && getBooleanPreferences(getApplicationContext(), PREF_KCA_NOTI_QUEST_FAIRY_GLOW); Bitmap src = KcaUtils.getFairyImageFromStorage(getApplicationContext(), viewBitmapId, dbHelper); Bitmap alpha = src.extractAlpha(); Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin, src.getHeight() + margin, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); if (glow_available) { Paint glow_paint = new Paint(); glow_paint.setColor(glowColor); glow_paint.setMaskFilter(new BlurMaskFilter(glowRadius, BlurMaskFilter.Blur.OUTER)); canvas.drawBitmap(alpha, halfMargin, halfMargin, glow_paint); } Paint color_paint = new Paint(); if (taiha_status) { color_paint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.colorHeavyDmgStateWarn), PorterDuff.Mode.MULTIPLY)); } else if (glow_available) { color_paint.setColorFilter(new PorterDuffColorFilter(glowColor2, PorterDuff.Mode.MULTIPLY)); } canvas.drawBitmap(src, halfMargin, halfMargin, color_paint); viewbutton.setImageBitmap(bmp); }
Example #10
Source File: IconCache.java From KAM with GNU General Public License v3.0 | 6 votes |
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; 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); }
Example #11
Source File: ImageTools.java From android-tv-launcher with MIT License | 6 votes |
/** *图片阴影 * @param originalBitmap */ public static Drawable drawImageDropShadow(Bitmap originalBitmap, Context context) { BlurMaskFilter blurFilter = new BlurMaskFilter(3,BlurMaskFilter.Blur.NORMAL); Paint shadowPaint = new Paint(); shadowPaint.setAlpha(80); shadowPaint.setColor(context.getResources().getColor(R.color.black)); shadowPaint.setMaskFilter(blurFilter); int[] offsetXY = new int[2]; Bitmap shadowBitmap = originalBitmap.extractAlpha(shadowPaint, offsetXY); Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true); if ( !shadowImage32.isPremultiplied() ) { shadowImage32.setPremultiplied( true ); } Canvas c = new Canvas(shadowImage32); c.drawBitmap(originalBitmap, offsetXY[0], offsetXY[1], null); return new BitmapDrawable(shadowImage32); }
Example #12
Source File: GameThread.java From FruitNinja with Apache License 2.0 | 6 votes |
public void startGame(int width, int height) { this.width = width; this.isRunning = true; this.projectileManager.setWidthAndHeight(width, height); this.timer.startGame(); this.self = executor.scheduleAtFixedRate(this, 0, 10, TimeUnit.MILLISECONDS); this.scorePaint.setColor(Color.MAGENTA); this.scorePaint.setAntiAlias(true); this.scorePaint.setTextSize(38.0f); this.linePaint.setAntiAlias(true); this.linePaint.setColor(Color.YELLOW); this.linePaint.setStyle(Paint.Style.STROKE); this.linePaint.setStrokeJoin(Paint.Join.ROUND); this.linePaint.setStrokeWidth(5.0f); this.linePaintBlur.set(this.linePaint); this.linePaintBlur.setMaskFilter(new BlurMaskFilter(9.0f, BlurMaskFilter.Blur.NORMAL)); }
Example #13
Source File: RxImageTool.java From RxTools-master with Apache License 2.0 | 6 votes |
/** * 可以对该图的非透明区域着色 * <p> * 有多种使用场景,常见如 Button 的 pressed 状态,View 的阴影状态等 * * @param iv * @param src * @param radius * @param color * @return */ private static Bitmap getDropShadow(ImageView iv, Bitmap src, float radius, int color) { final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setColor(color); final int width = src.getWidth(), height = src.getHeight(); final Bitmap dest = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(dest); final Bitmap alpha = src.extractAlpha(); canvas.drawBitmap(alpha, 0, 0, paint); final BlurMaskFilter filter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER); paint.setMaskFilter(filter); canvas.drawBitmap(alpha, 0, 0, paint); iv.setImageBitmap(dest); return dest; }
Example #14
Source File: SingleWeekView.java From CalendarView with Apache License 2.0 | 6 votes |
public SingleWeekView(Context context) { super(context); mRingPaint.setAntiAlias(true); mRingPaint.setColor(mSchemePaint.getColor()); mRingPaint.setStyle(Paint.Style.STROKE); mRingPaint.setStrokeWidth(dipToPx(context, 1)); setLayerType(View.LAYER_TYPE_SOFTWARE, mRingPaint); mRingPaint.setMaskFilter(new BlurMaskFilter(30, BlurMaskFilter.Blur.SOLID)); mDisablePaint.setColor(0xFF9f9f9f); mDisablePaint.setAntiAlias(true); mDisablePaint.setStrokeWidth(dipToPx(context,2)); mDisablePaint.setFakeBoldText(true); mH = dipToPx(context, 18); }
Example #15
Source File: SingleMonthView.java From CalendarView with Apache License 2.0 | 6 votes |
public SingleMonthView(Context context) { super(context); mRingPaint.setAntiAlias(true); mRingPaint.setColor(mSchemePaint.getColor()); mRingPaint.setStyle(Paint.Style.STROKE); mRingPaint.setStrokeWidth(dipToPx(context, 1)); setLayerType(View.LAYER_TYPE_SOFTWARE, mRingPaint); mRingPaint.setMaskFilter(new BlurMaskFilter(30, BlurMaskFilter.Blur.SOLID)); mDisablePaint.setColor(0xFF9f9f9f); mDisablePaint.setAntiAlias(true); mDisablePaint.setStrokeWidth(dipToPx(context,2)); mDisablePaint.setFakeBoldText(true); mH = dipToPx(context, 18); }
Example #16
Source File: FullMonthView.java From CalendarView with Apache License 2.0 | 6 votes |
public FullMonthView(Context context) { super(context); mRectPaint.setStyle(Paint.Style.STROKE); mRectPaint.setStrokeWidth(dipToPx(context, 0.5f)); mRectPaint.setColor(0x88efefef); mSchemeBasicPaint.setAntiAlias(true); mSchemeBasicPaint.setStyle(Paint.Style.FILL); mSchemeBasicPaint.setTextAlign(Paint.Align.CENTER); mSchemeBasicPaint.setFakeBoldText(true); //兼容硬件加速无效的代码 setLayerType(View.LAYER_TYPE_SOFTWARE, mSchemeBasicPaint); //4.0以上硬件加速会导致无效 mSelectedPaint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.SOLID)); }
Example #17
Source File: FullWeekView.java From CalendarView with Apache License 2.0 | 6 votes |
public FullWeekView(Context context) { super(context); mRectPaint.setStyle(Paint.Style.STROKE); mRectPaint.setStrokeWidth(dipToPx(context, 0.5f)); mRectPaint.setColor(0x88efefef); mSchemeBasicPaint.setAntiAlias(true); mSchemeBasicPaint.setStyle(Paint.Style.FILL); mSchemeBasicPaint.setTextAlign(Paint.Align.CENTER); mSchemeBasicPaint.setColor(0xffed5353); mSchemeBasicPaint.setFakeBoldText(true); //兼容硬件加速无效的代码 setLayerType(View.LAYER_TYPE_SOFTWARE, mSchemeBasicPaint); //4.0以上硬件加速会导致无效 mSelectedPaint.setMaskFilter(new BlurMaskFilter(50, BlurMaskFilter.Blur.SOLID)); }
Example #18
Source File: ShadowOval.java From ZDepthShadow with MIT License | 6 votes |
@Override public void setParameter(ZDepthParam param, int left, int top, int right, int bottom) { mRectTopShadow.left = left; mRectTopShadow.top = top + param.mOffsetYTopShadowPx; mRectTopShadow.right = right; mRectTopShadow.bottom = bottom + param.mOffsetYTopShadowPx; mRectBottomShadow.left = left; mRectBottomShadow.top = top + param.mOffsetYBottomShadowPx; mRectBottomShadow.right = right; mRectBottomShadow.bottom = bottom + param.mOffsetYBottomShadowPx; mTopShadow.getPaint().setColor(Color.argb(param.mAlphaTopShadow, 0, 0, 0)); if (0 < param.mBlurTopShadowPx) { mTopShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurTopShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mTopShadow.getPaint().setMaskFilter(null); } mBottomShadow.getPaint().setColor(Color.argb(param.mAlphaBottomShadow, 0, 0, 0)); if (0 < param.mBlurBottomShadowPx) { mBottomShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurBottomShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mBottomShadow.getPaint().setMaskFilter(null); } }
Example #19
Source File: GuideLayout.java From NewbieGuide with Apache License 2.0 | 6 votes |
private void init() { mPaint = new Paint(); mPaint.setAntiAlias(true); PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR); mPaint.setXfermode(xfermode); //设置画笔遮罩滤镜,可以传入BlurMaskFilter或EmbossMaskFilter,前者为模糊遮罩滤镜而后者为浮雕遮罩滤镜 //这个方法已经被标注为过时的方法了,如果你的应用启用了硬件加速,你是看不到任何阴影效果的 mPaint.setMaskFilter(new BlurMaskFilter(10, BlurMaskFilter.Blur.INNER)); //关闭当前view的硬件加速 setLayerType(LAYER_TYPE_SOFTWARE, null); //ViewGroup默认设定为true,会使onDraw方法不执行,如果复写了onDraw(Canvas)方法,需要清除此标记 setWillNotDraw(false); touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); }
Example #20
Source File: RadialPicker.java From rnd-android-wear-tesla with MIT License | 6 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); int width = canvas.getWidth(); float height = canvas.getHeight(); int maxValueStepsCount = mMaxValue - mMinValue + 1; mValueStep = (height / maxValueStepsCount); mRadialPaint.setMaskFilter(new BlurMaskFilter(20, BlurMaskFilter.Blur.NORMAL)); updatePaintColorByValue(); canvas.drawCircle(width / 2, height * 0.65f, width / 3.5f + width * 0.38f * (((float) (mValue) - mMinValue) / (mMaxValue - mMinValue)), mRadialPaint); scaleSieveIfNeeded(width); Paint p2 = new Paint(); p2.setAntiAlias(true); canvas.drawBitmap(mSieveScaledBitmap, 0, 0, p2); }
Example #21
Source File: MaskImageView.java From libcommon with Apache License 2.0 | 6 votes |
@Override protected synchronized void onSizeChanged(int width, int height, int old_width, int old_height) { super.onSizeChanged(width, height, old_width, old_height); if ((width == 0) || (height == 0)) return; // paddingを考慮してマスク用のDrawableのサイズを計算 final int padding_left = getPaddingLeft(); final int padding_top = getPaddingTop(); final int sz = Math.min(width - padding_left - getPaddingRight(), height - padding_top - getPaddingBottom()); final int left = (width - sz) / 2 + padding_left; final int top = (height - sz) / 2 + padding_top; mMaskBounds.set(left, top, left + sz, top + sz); if (sz > 3) { mMaskedPaint.setMaskFilter(new BlurMaskFilter(sz * 2 / 3.0f, BlurMaskFilter.Blur.NORMAL)); } // View自体のサイズはそのまま mViewBoundsF.set(0, 0, width, height); if (mMaskDrawable != null) { mMaskDrawable.setBounds(mMaskBounds); } }
Example #22
Source File: CommaWeekView.java From android with MIT License | 6 votes |
public CommaWeekView(Context context) { super(context); mTextPaint.setTextSize(dipToPx(context, 8)); mTextPaint.setColor(0xffffffff); mTextPaint.setAntiAlias(true); mTextPaint.setFakeBoldText(true); mSchemeBasicPaint.setAntiAlias(true); mSchemeBasicPaint.setStyle(Paint.Style.FILL); mSchemeBasicPaint.setTextAlign(Paint.Align.CENTER); mSchemeBasicPaint.setColor(0xffed5353); mSchemeBasicPaint.setFakeBoldText(true); mRadio = dipToPx(getContext(), 7); mPadding = dipToPx(getContext(), 4); Paint.FontMetrics metrics = mSchemeBasicPaint.getFontMetrics(); mSchemeBaseLine = mRadio - metrics.descent + (metrics.bottom - metrics.top) / 2 + dipToPx(getContext(), 1); //兼容硬件加速无效的代码 setLayerType(View.LAYER_TYPE_SOFTWARE, mSchemeBasicPaint); //4.0以上硬件加速会导致无效 mSchemeBasicPaint.setMaskFilter(new BlurMaskFilter(25, BlurMaskFilter.Blur.SOLID)); }
Example #23
Source File: CommaMonthView.java From android with MIT License | 6 votes |
public CommaMonthView(Context context) { super(context); mTextPaint.setTextSize(dipToPx(context, 8)); mTextPaint.setColor(0xffffffff); mTextPaint.setAntiAlias(true); mTextPaint.setFakeBoldText(true); mSchemeBasicPaint.setAntiAlias(true); mSchemeBasicPaint.setStyle(Paint.Style.FILL); mSchemeBasicPaint.setTextAlign(Paint.Align.CENTER); mSchemeBasicPaint.setFakeBoldText(true); mRadio = dipToPx(getContext(), 7); mPadding = dipToPx(getContext(), 4); Paint.FontMetrics metrics = mSchemeBasicPaint.getFontMetrics(); mSchemeBaseLine = mRadio - metrics.descent + (metrics.bottom - metrics.top) / 2 + dipToPx(getContext(), 1); //兼容硬件加速无效的代码 setLayerType(View.LAYER_TYPE_SOFTWARE, mSchemeBasicPaint); //4.0以上硬件加速会导致无效 mSchemeBasicPaint.setMaskFilter(new BlurMaskFilter(25, BlurMaskFilter.Blur.SOLID)); }
Example #24
Source File: MyViewWithTransparentArea.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
public MyViewWithTransparentArea(Context context) { super(context); overlayDefault = BitmapFactory.decodeResource(getResources(),R.drawable.dwarf); overlayDefault = Bitmap.createScaledBitmap( overlayDefault, 800, 800, false); overlay = BitmapFactory.decodeResource(getResources(),R.drawable.dwarf).copy(Bitmap.Config.ARGB_8888, true); c2 = new Canvas(overlay); pTouch = new Paint(Paint.ANTI_ALIAS_FLAG); pTouch.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); pTouch.setColor(Color.TRANSPARENT); pTouch.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL)); }
Example #25
Source File: KcaViewButtonService.java From kcanotify with GNU General Public License v3.0 | 6 votes |
private void setFairyImage() { boolean glow_available = fairy_glow_on && getBooleanPreferences(getApplicationContext(), PREF_KCA_NOTI_QUEST_FAIRY_GLOW); Bitmap src = KcaUtils.getFairyImageFromStorage(getApplicationContext(), viewBitmapId, dbHelper); Bitmap alpha = src.extractAlpha(); Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin, src.getHeight() + margin, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bmp); if (glow_available) { Paint glow_paint = new Paint(); glow_paint.setColor(glowColor); glow_paint.setMaskFilter(new BlurMaskFilter(glowRadius, BlurMaskFilter.Blur.OUTER)); canvas.drawBitmap(alpha, halfMargin, halfMargin, glow_paint); } Paint color_paint = new Paint(); if (taiha_status) { color_paint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.colorHeavyDmgStateWarn), PorterDuff.Mode.MULTIPLY)); } else if (glow_available) { color_paint.setColorFilter(new PorterDuffColorFilter(glowColor2, PorterDuff.Mode.MULTIPLY)); } canvas.drawBitmap(src, halfMargin, halfMargin, color_paint); viewbutton.setImageBitmap(bmp); }
Example #26
Source File: Utilities.java From TurboLauncher with Apache License 2.0 | 6 votes |
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); }
Example #27
Source File: HolographicOutlineHelper.java From TurboLauncher with Apache License 2.0 | 6 votes |
private HolographicOutlineHelper(Context context) { final float scale = LauncherAppState.getInstance().getScreenDensity(); mMinOuterBlurRadius = (int) (scale * 1.0f); mMaxOuterBlurRadius = (int) (scale * 12.0f); mExtraThickOuterBlurMaskFilter = new BlurMaskFilter(scale * 12.0f, BlurMaskFilter.Blur.OUTER); mThickOuterBlurMaskFilter = new BlurMaskFilter(scale * 6.0f, BlurMaskFilter.Blur.OUTER); mMediumOuterBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.OUTER); mThinOuterBlurMaskFilter = new BlurMaskFilter(scale * 1.0f, BlurMaskFilter.Blur.OUTER); mExtraThickInnerBlurMaskFilter = new BlurMaskFilter(scale * 6.0f, BlurMaskFilter.Blur.NORMAL); mThickInnerBlurMaskFilter = new BlurMaskFilter(scale * 4.0f, BlurMaskFilter.Blur.NORMAL); mMediumInnerBlurMaskFilter = new BlurMaskFilter(scale * 2.0f, BlurMaskFilter.Blur.NORMAL); mHolographicPaint.setFilterBitmap(true); mHolographicPaint.setAntiAlias(true); mBlurPaint.setFilterBitmap(true); mBlurPaint.setAntiAlias(true); mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mErasePaint.setFilterBitmap(true); mErasePaint.setAntiAlias(true); }
Example #28
Source File: ShadowRect.java From ZDepthShadow with MIT License | 6 votes |
@Override public void setParameter(ZDepthParam param, int left, int top, int right, int bottom) { mRectTopShadow.left = left; mRectTopShadow.top = (int) (top + param.mOffsetYTopShadowPx); mRectTopShadow.right = right; mRectTopShadow.bottom = (int) (bottom + param.mOffsetYTopShadowPx); mRectBottomShadow.left = left; mRectBottomShadow.top = (int) (top + param.mOffsetYBottomShadowPx); mRectBottomShadow.right = right; mRectBottomShadow.bottom = (int) (bottom + param.mOffsetYBottomShadowPx); mTopShadow.getPaint().setColor(Color.argb(param.mAlphaTopShadow, 0, 0, 0)); if (0 < param.mBlurTopShadowPx) { mTopShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurTopShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mTopShadow.getPaint().setMaskFilter(null); } mBottomShadow.getPaint().setColor(Color.argb(param.mAlphaBottomShadow, 0, 0, 0)); if (0 < param.mBlurBottomShadowPx) { mBottomShadow.getPaint().setMaskFilter(new BlurMaskFilter(param.mBlurBottomShadowPx, BlurMaskFilter.Blur.NORMAL)); } else { mBottomShadow.getPaint().setMaskFilter(null); } }
Example #29
Source File: StackView.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
HolographicHelper(Context context) { mDensity = context.getResources().getDisplayMetrics().density; mHolographicPaint.setFilterBitmap(true); mHolographicPaint.setMaskFilter(TableMaskFilter.CreateClipTable(0, 30)); mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); mErasePaint.setFilterBitmap(true); mSmallBlurMaskFilter = new BlurMaskFilter(2 * mDensity, BlurMaskFilter.Blur.NORMAL); mLargeBlurMaskFilter = new BlurMaskFilter(4 * mDensity, BlurMaskFilter.Blur.NORMAL); }
Example #30
Source File: BlurMaskFilterActivity.java From android-graphics-demo with Apache License 2.0 | 5 votes |
private void applyFilter( TextView textView, BlurMaskFilter.Blur style) { if (Build.VERSION.SDK_INT >= 11) { ViewUtil.setSoftwareLayerType(textView); } textView.setText(style.name()); BlurMaskFilter filter = new BlurMaskFilter(textView.getTextSize() / 10, style); textView.getPaint().setMaskFilter(filter); }