本文整理汇总了Java中android.graphics.BlurMaskFilter.Blur类的典型用法代码示例。如果您正苦于以下问题:Java Blur类的具体用法?Java Blur怎么用?Java Blur使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Blur类属于android.graphics.BlurMaskFilter包,在下文中一共展示了Blur类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ShadowGenerator
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
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);
}
示例2: ShadowGenerator
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
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);
}
示例3: createPillWithShadow
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
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;
}
示例4: init
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
/**
* 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);
}
示例5: init
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
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();
}
示例6: dropShadow
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
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;
}
}
示例7: TextSeekBarDrawable
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
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();
}
示例8: initPaints
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
/**
* @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));
}
示例9: init
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
/**
* 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);
}
示例10: getGlow
import android.graphics.BlurMaskFilter.Blur; //导入依赖的package包/类
/**
* 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;
}
}