本文整理汇总了Java中android.graphics.Paint.FILTER_BITMAP_FLAG属性的典型用法代码示例。如果您正苦于以下问题:Java Paint.FILTER_BITMAP_FLAG属性的具体用法?Java Paint.FILTER_BITMAP_FLAG怎么用?Java Paint.FILTER_BITMAP_FLAG使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.FILTER_BITMAP_FLAG属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IconCache
public IconCache(Context context, InvariantDeviceProfile inv) {
mContext = context;
mPackageManager = context.getPackageManager();
mUserManager = UserManagerCompat.getInstance(mContext);
mLauncherApps = LauncherAppsCompat.getInstance(mContext);
mIconDpi = inv.fillResIconDpi;
mIconDb = new IconDB(context, inv.iconBitmapSize);
mLowResCanvas = new Canvas();
mLowResPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
mIconProvider = IconProvider.loadByName(context.getString(R.string.icon_provider_class),
context);
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
mActivityBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color);
TypedArray ta = context.obtainStyledAttributes(new int[]{R.attr.colorSecondary});
mPackageBgColor = ta.getColor(0, 0);
ta.recycle();
mLowResOptions = new BitmapFactory.Options();
// Always prefer RGB_565 config for low res. If the bitmap has transparency, it will
// automatically be loaded as ALPHA_8888.
mLowResOptions.inPreferredConfig = Bitmap.Config.RGB_565;
}
示例2: circleCrop
private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
if (source == null) return null;
int size = Math.min(source.getWidth(), source.getHeight());
int x = (source.getWidth() - size) / 2;
int y = (source.getHeight() - size) / 2;
// TODO this could be acquired from the pool too
Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
if (result == null) {
result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
}
Canvas canvas = new Canvas(result);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG | Paint
.ANTI_ALIAS_FLAG);
paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader
.TileMode.CLAMP));
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
return result;
}
示例3: init
private void init() {
Log.i(Tag, "init");
mLineWidth = changeDp(1);
mLineHeight = changeDp(3);
mFixLineHeight = changeDp(6);
mSunRadius = changeDp(12);
mLineColor = Color.RED;
mLineLevel = 30;
//线的配置
mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mLinePaint.setColor(mLineColor);
mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
// 设置画笔宽度
mLinePaint.setStrokeWidth(mLineWidth);
mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
| Paint.FILTER_BITMAP_FLAG);
debugRect = new Rect();
mouthRect = new RectF();
}
示例4: dispatchDraw
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mChanged && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
post(new Runnable() {
@Override
public void run() {
if (mAttached && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
final int layerType = getLayerType();
// If it's already a hardware layer, it'll be built anyway.
if (layerType != LAYER_TYPE_HARDWARE || mFirst) {
mFirst = false;
setLayerType(LAYER_TYPE_HARDWARE, null);
buildLayer();
setLayerType(LAYER_TYPE_NONE, null);
}
}
}
});
mChanged = false;
}
PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint
.FILTER_BITMAP_FLAG);
canvas.setDrawFilter(pfd);
}
示例5: CropView
public CropView(Context context, AttributeSet attrs) {
super(context, attrs);
mDetectorCompat = new GestureDetectorCompat(getContext(), new GestureListener());
mScaleDetector = new ScaleGestureDetector(getContext(), new ScaleGestureListener());
mBitmapOptions = new BitmapFactory.Options();
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
mRectPaint = new Paint();
mRectPaint.setStyle(Paint.Style.STROKE);
mRectPaint.setStrokeWidth(1f);
mBorderPaint = new Paint();
mBorderPaint.setColor(Color.BLACK);
mCanvasDrawRect = new Rect();
mImageDrawRect = new Rect();
mCacheRect = new Rect();
mOutputRect = new Rect();
mSmallImage = false;
mImageOK = false;
mLabelCollection = new LabelCollection();
}
示例6: init
private void init(Context context, AttributeSet attrs, int defStyle) {
TypedArray type = context.obtainStyledAttributes(attrs, R.styleable.ShadeTriangleTotalForRankView, 0, 0);
duration = (long) type.getFloat(R.styleable.ShadeTriangleTotalForRankView_shade_duration, 18000f);
mImageSource_total = type.getResourceId(R.styleable.ShadeTriangleTotalForRankView_image_total, R.drawable.mask_triangle_total);
mTotal_bitmap = readBitMap(context, mImageSource_total);
mPaint_Mask.setStyle(Paint.Style.FILL);
mPaint_Mask.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mPaint_Pic.setFilterBitmap(true);
pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
src = new Rect();
dst = new Rect();
path = new Path();
}
示例7: ShadowGenerator
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);
}
示例8: resizeBitmapByScale
public static Bitmap resizeBitmapByScale(
Bitmap bitmap, float scale, boolean recycle) {
int width = Math.round(bitmap.getWidth() * scale);
int height = Math.round(bitmap.getHeight() * scale);
if (width == bitmap.getWidth()
&& height == bitmap.getHeight()) return bitmap;
Bitmap target = Bitmap.createBitmap(width, height, getConfig(bitmap));
Canvas canvas = new Canvas(target);
canvas.scale(scale, scale);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
canvas.drawBitmap(bitmap, 0, 0, paint);
if (recycle) bitmap.recycle();
return target;
}
示例9: ClickShadowView
public ClickShadowView(Context context) {
super(context);
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
mPaint.setColor(Color.BLACK);
mShadowPadding = getResources().getDimension(R.dimen.blur_size_click_shadow);
mShadowOffset = getResources().getDimension(R.dimen.click_shadow_high_shift);
}
示例10: fastBlur
/**
* 快速模糊图片
* <p>先缩小原图,对小图进行模糊,再放大回原先尺寸</p>
*
* @param src 源图片
* @param scale 缩放比例(0...1)
* @param radius 模糊半径
* @param recycle 是否回收
* @return 模糊后的图片
*/
public static Bitmap fastBlur(Bitmap src, float scale, float radius, boolean recycle) {
if (isEmptyBitmap(src)) return null;
int width = src.getWidth();
int height = src.getHeight();
int scaleWidth = (int) (width * scale + 0.5f);
int scaleHeight = (int) (height * scale + 0.5f);
if (scaleWidth == 0 || scaleHeight == 0) return null;
Bitmap scaleBitmap = Bitmap.createScaledBitmap(src, scaleWidth, scaleHeight, true);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
Canvas canvas = new Canvas();
PorterDuffColorFilter filter = new PorterDuffColorFilter(
Color.TRANSPARENT, PorterDuff.Mode.SRC_ATOP);
paint.setColorFilter(filter);
canvas.scale(scale, scale);
canvas.drawBitmap(scaleBitmap, 0, 0, paint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
scaleBitmap = renderScriptBlur(Utils.getContext(), scaleBitmap, radius);
} else {
scaleBitmap = stackBlur(scaleBitmap, (int) radius, recycle);
}
if (scale == 1) return scaleBitmap;
Bitmap ret = Bitmap.createScaledBitmap(scaleBitmap, width, height, true);
if (scaleBitmap != null && !scaleBitmap.isRecycled()) scaleBitmap.recycle();
if (recycle && !src.isRecycled()) src.recycle();
return ret;
}
示例11: PercentClipHelper
PercentClipHelper(@NonNull View view, @Nullable AttributeSet attrs) {
this.view = view;
this.params = new ClipParams(view.getContext(), attrs);
this.paint = new Paint(Paint.ANTI_ALIAS_FLAG);
this.maskPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
this.maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
view.setWillNotDraw(false);
}
示例12: SwitchDrawable
SwitchDrawable(
@Nonnull Bitmap startBitmap,
@Nonnull Rect startBitmapSrcBounds,
float startFontSize,
@Nonnull Bitmap endBitmap,
@Nonnull Rect endBitmapSrcBounds,
float endFontSize) {
currentBitmap = startBitmap;
currentBitmapSrcBounds = startBitmapSrcBounds;
this.endBitmap = endBitmap;
this.endBitmapSrcBounds = endBitmapSrcBounds;
switchThreshold = startFontSize / (startFontSize + endFontSize);
paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
}
示例13: upscaleToScreenSize
private Bitmap upscaleToScreenSize(Bitmap bitmap) {
WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
display.getRealMetrics(mDisplayMetrics);
int width = mDisplayMetrics.widthPixels, height = mDisplayMetrics.heightPixels;
float widthFactor = 0f, heightFactor = 0f;
if (width > bitmap.getWidth()) {
widthFactor = ((float) width) / bitmap.getWidth();
}
if (height > bitmap.getHeight()) {
heightFactor = ((float) height) / bitmap.getHeight();
}
float upscaleFactor = Math.max(widthFactor, heightFactor);
if (upscaleFactor <= 0) {
return bitmap;
}
int scaledWidth = (int) (bitmap.getWidth() * upscaleFactor);
int scaledHeight = (int) (bitmap.getHeight() * upscaleFactor);
Bitmap scaled = Bitmap.createScaledBitmap(
bitmap,
scaledWidth,
scaledHeight, false);
Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas();
canvas.setBitmap(result);
Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
if (widthFactor > heightFactor) {
canvas.drawBitmap(scaled, 0, (height - scaledHeight) / 2, paint);
} else {
canvas.drawBitmap(scaled, (width - scaledWidth) / 2, 0, paint);
}
return result;
}
示例14: init
private void init() {
rectPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
loaderView.setRectColor(rectPaint);
setValueAnimator(0.5f, 1, ObjectAnimator.INFINITE);
}
示例15: init
private void init(Context context, AttributeSet attrs) {
//抗锯齿和位图滤波
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
//读取xml文件中的配置
if (attrs != null) {
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PowerfulEditText);
for (int i = 0; i < array.getIndexCount(); i++) {
int attr = array.getIndex(i);
switch (attr) {
case R.styleable.PowerfulEditText_clearDrawable:
mClearResId = array.getResourceId(attr, DEFAULT_CLEAR_RES);
break;
case R.styleable.PowerfulEditText_visibleDrawable:
mVisibleResId = array.getResourceId(attr, DEFAULT_VISIBLE_RES);
break;
case R.styleable.PowerfulEditText_invisibleDrawable:
mInvisibleResId = array.getResourceId(attr, DEFAULT_INVISIBLE_RES);
break;
case R.styleable.PowerfulEditText_BtnWidth:
mBtnWidth = array.getDimensionPixelSize(attr, DEFAULT_BUTTON_WIDTH);
break;
case R.styleable.PowerfulEditText_BtnSpacing:
mBtnPadding = array.getDimensionPixelSize(attr, DEFAULT_BUTTON_PADDING);
break;
case R.styleable.PowerfulEditText_borderStyle:
mBorderStyle = array.getString(attr);
break;
case R.styleable.PowerfulEditText_styleColor:
mStyleColor = array.getColor(attr, DEFAULT_STYLE_COLOR);
break;
}
}
array.recycle();
}
//初始化按钮显示的Bitmap
mBitmapClear = createBitmap(context, mClearResId, DEFAULT_CLEAR_RES);
mBitmapVisible = createBitmap(context, mVisibleResId, DEFAULT_VISIBLE_RES);
mBitmapInvisible = createBitmap(context, mInvisibleResId, DEFAULT_INVISIBLE_RES);
//如果自定义,则使用自定义的值,否则使用默认值
if (mBtnPadding == 0) {
mBtnPadding = DEFAULT_BUTTON_PADDING;
}
if (mBtnWidth == 0) {
mBtnWidth = DEFAULT_BUTTON_WIDTH;
}
//给文字设置一个padding,避免文字和按钮重叠了
mTextPaddingRight = mBtnPadding * 4 + mBtnWidth * 2;
//按钮出现和消失的动画
mGoneAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(ANIMATOR_TIME);
mVisibleAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(ANIMATOR_TIME);
//是否是密码样式
isPassword =
getInputType() == (InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT);
}