本文整理汇总了Java中android.graphics.PaintFlagsDrawFilter类的典型用法代码示例。如果您正苦于以下问题:Java PaintFlagsDrawFilter类的具体用法?Java PaintFlagsDrawFilter怎么用?Java PaintFlagsDrawFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PaintFlagsDrawFilter类属于android.graphics包,在下文中一共展示了PaintFlagsDrawFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
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();
}
示例2: dispatchDraw
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
@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);
}
示例3: getRoundedCornerBitmap
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
paint.setDither(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例4: onDraw
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
public void onDraw(Canvas canvas) {
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, 3));
int W = canvas.getWidth();
int H = canvas.getHeight();
Rect frame = CameraManager.get().getFramingRect();
if (frame != null) {
drawCover(canvas, frame, W, H);
if (this.resultBitmap != null) {
canvas.drawBitmap(this.resultBitmap, (float) frame.left, (float) frame.top, this.paint);
return;
}
drawScanningLine(canvas, frame);
drawRectEdge(canvas, frame);
this.paint.reset();
postInvalidateDelayed(ANIMATION_DELAY);
}
}
示例5: RoundImageView
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
public RoundImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RoundImageView);
float mRadius = array.getDimension(R.styleable.RoundImageView_radius, 10);
rids[0] = mRadius;
rids[1] = mRadius;
rids[2] = mRadius;
rids[3] = mRadius;
rids[4] = 0f;
rids[5] = 0f;
rids[6] = 0f;
rids[7] = 0f;
array.recycle();
mPath = new Path();
paintFlagsDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
setLayerType(View.LAYER_TYPE_HARDWARE, null);
}
示例6: onDraw
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
if (mAnimator_visible.isRunning()) {
int x = (int) mAnimator_visible.getAnimatedValue();
drawClear(x, canvas);
invalidate();
} else if (isVisible) {
drawClear(0, canvas);
}
if (mAnimator_gone.isRunning()) {
float scale = (float) mAnimator_gone.getAnimatedValue();
drawClearGone(scale, canvas);
invalidate();
}
}
示例7: drawTargetBitmap
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
private void drawTargetBitmap(Canvas canvas,int alpha) {
// mCanvas =canvas;
mPaint = new Paint();
mPaint.setColor(mSelectedColor);
mPaint.setAntiAlias(true);
mPaint.setDither(true);
mPaint.setAlpha(alpha);
mCanvas.drawRect(mIconRect, mPaint);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mPaint.setAlpha(255);
mCanvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
if (mIconBitmapSelected != null)
mCanvas.drawBitmap(mIconBitmapSelected, mIconRect.left, mIconRect.top, mPaint);
else
mCanvas.drawBitmap(mIconBitmapNormal, mIconRect.left, mIconRect.top, mPaint);
canvas.drawBitmap(mBitmap, 0, 0, null);
}
示例8: init
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
private void init() {
mStrokeWidth = AppUtil.dip2px(2);
mPaint = new Paint();
mPaint.setColor(0xFF0000FF);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeWidth(mStrokeWidth);
mPaint.setAntiAlias(true);
mPaint.setDither(false);
mBGPaint = new Paint();
mBGPaint.setColor(0xFFAAAAAA);
mBGPaint.setStyle(Paint.Style.STROKE);
mBGPaint.setStrokeWidth(mStrokeWidth);
mBGPaint.setAntiAlias(true);
mBGPaint.setDither(false);
mDegree = 0;
pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);
}
示例9: drawable2Bitmap
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
/**
* drawable转bitmap
*处理不同情况下的图片显示
* @param drawable
* @return
*/
private Bitmap drawable2Bitmap(Drawable drawable) {
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
drawable.setBounds(0, 0, w, h);
if ((w >= h) && CropType.centerTop.equals(cropType)) {
canvas.translate((h - w) * 0.5F, 0);
} else if ((w >= h) && CropType.center.equals(cropType)) {
canvas.translate((h - w) * 0.5F, 0);
} else if ((w < h) && CropType.center.equals(cropType)) {
canvas.translate(0, (w - h) * 0.5F);
}
drawable.draw(canvas);
return bitmap;
}
示例10: drawCircles
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
private void drawCircles(Canvas canvas) {
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
| Paint.FILTER_BITMAP_FLAG));
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(0xffffffff);
RectF r = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
canvas.drawRect(r, paint);
for (int i = radiusArray.length - 1; i >= 0; i--) {
if (radiusArray[i] >= baseRadius) {
paint.setColor(getColor(radiusArray[i]));
canvas.drawCircle(canvas.getWidth() / 2,
canvas.getHeight() / 2, radiusArray[i], paint);
}
}
paint.setColor(Color.argb(255, 0xfe, 0xaa, 0x4b));
canvas.drawCircle(canvas.getWidth() / 2, canvas.getHeight() / 2,
baseRadius, paint);
}
示例11: RoseBoxSeekBarView
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
/**
* @param context
* @param attrs
* @param defStyle
*/
public RoseBoxSeekBarView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.mContext = context;
mResources = context.getApplicationContext().getResources();
drawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
| Paint.FILTER_BITMAP_FLAG);
int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
int cacheSize = maxMemory / 8;
mMemoryCache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(String key, Bitmap bitmap) {
// 重写此方法来衡量每张图片的大小,默认返回图片数量。
return bitmap.getByteCount() / 1024;
}
};
// typeface = Typeface.createFromAsset(getContext().getAssets(),
// "fonts/HELVETICANEUELTSTD-THEX.OTF");
}
示例12: onDraw
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));//抗锯齿
if (mAnimator_visible.isRunning()) {
int x = (int) mAnimator_visible.getAnimatedValue();
drawClear(x,canvas);
invalidate();
}else if (isVisible){
drawClear(0,canvas);
}
if(mAnimator_gone.isRunning()){
float scale = (float) mAnimator_gone.getAnimatedValue();
drawClearGone(scale, canvas);
invalidate();
}
}
示例13: onRectChanged
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
protected void onRectChanged(RectF rectf)
{
super.onRectChanged(rectf);
o = new RectF();
o.left = rectf.centerX() - 15.5F * mDensity;
o.top = rectf.top + 2.0F * mDensity;
o.right = o.left + 31F * mDensity;
o.bottom = o.top + 31F * mDensity;
p = Bitmap.createBitmap((int)rectf.width(), (int)rectf.height(), android.graphics.Bitmap.Config.ARGB_8888);
r = false;
if (q == null)
{
q = new Canvas();
q.setDrawFilter(new PaintFlagsDrawFilter(0, 7));
}
q.setBitmap(p);
}
示例14: onDraw
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
mPaint.setColor(Color.RED);
mPaint.setAntiAlias(true);
for (int index = 0; index < mListPoint.size(); index++)
{
if (index > 0)
{
canvas.drawLine(mListPoint.get(index - 1).get(X_KEY), mListPoint.get(index - 1)
.get(Y_KEY),
mListPoint.get(index).get(X_KEY), mListPoint.get(index).get(Y_KEY), mPaint);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG
| Paint.FILTER_BITMAP_FLAG));
}
}
}
示例15: init
import android.graphics.PaintFlagsDrawFilter; //导入依赖的package包/类
protected void init() {
bgPaint = new Paint();
bgPaint.setAntiAlias(true);
bgPaint.setColor(backgroundColor);
focusPaint = new Paint();
focusPaint.setAntiAlias(true);
focusPaint.setColor(focusColor);
animatorSet = new AnimatorSet();
bgRectF = new RectF();
mDrawFilter = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
this.setBackgroundResource(0);
}