当前位置: 首页>>代码示例>>Java>>正文


Java Paint.setAntiAlias方法代码示例

本文整理汇总了Java中android.graphics.Paint.setAntiAlias方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.setAntiAlias方法的具体用法?Java Paint.setAntiAlias怎么用?Java Paint.setAntiAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Paint的用法示例。


在下文中一共展示了Paint.setAntiAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeCircleFromBitmap

import android.graphics.Paint; //导入方法依赖的package包/类
public Bitmap makeCircleFromBitmap(Bitmap output) {
	Canvas canvas = new Canvas(output);
	canvas.drawARGB(0, 0, 0, 0);
	Paint paint = new Paint();
	paint.setAntiAlias(true);
	if (rippleColor == null) {
		paint.setColor(makePressColor(255));
	}else {
		paint.setColor(rippleColor);
	}
	canvas.drawCircle(x, y, radius, paint);
	if (radius > getHeight() / rippleSize)
		radius += rippleSpeed;
	if (radius >= getWidth()) {
		x = -1;
		y = -1;
		radius = getHeight() / rippleSize;
		if(isEnabled() && clickAfterRipple == true && onClickListener != null)
			onClickListener.onClick(this);
	}
	return output;
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:23,代码来源:RippleView.java

示例2: circleCrop

import android.graphics.Paint; //导入方法依赖的package包/类
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;

    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.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
    paint.setAntiAlias(true);
    float r = size / 2f;
    canvas.drawCircle(r, r, r, paint);
    return result;
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:23,代码来源:GlideCircleTransform.java

示例3: toRoundCorner

import android.graphics.Paint; //导入方法依赖的package包/类
/**
 * 转为圆角图片
 *
 * @param src     源图片
 * @param radius  圆角的度数
 * @param recycle 是否回收
 * @return 圆角图片
 */
public static Bitmap toRoundCorner(final Bitmap src, final float radius, final boolean recycle) {
    if (null == src) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawRoundRect(new RectF(rect), radius, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:24,代码来源:ImageUtils.java

示例4: onDraw

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int width = getWidth();
    int height = getHeight();

    Paint paint = new Paint();
    paint.setColor(Color.rgb(255, 255, 255));
    paint.setAntiAlias(true);
    paint.setStrokeWidth(t(5));

    canvas.drawLine(0, 0, 0, t(18), paint);
    canvas.drawLine(0, 0, t(18), 0, paint);

    canvas.drawLine(0, height - t(18), 0, height, paint);
    canvas.drawLine(0, height, t(18), height, paint);

    canvas.drawLine(width - t(18), 0, width, 0, paint);
    canvas.drawLine(width, 0, width, t(18), paint);

    canvas.drawLine(width, height - t(18), width, height, paint);
    canvas.drawLine(width - t(18), height, width, height, paint);
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:24,代码来源:MyImageView.java

示例5: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.beautify);
    width = bitmap.getWidth();
    height = bitmap.getHeight();
    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    paint.setShader(new LinearGradient(0, 0, 0, height, 0x00000000, 0xff000000, Shader.TileMode.CLAMP));

    Matrix matrix = new Matrix();
    matrix.setScale(1, -1);
    //matrix.setRotate(180); 不能形成镜像效果
    rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);

    paint1 = new Paint();
    paint1.setAntiAlias(true);
    paint1.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    paint1.setShader(new LinearGradient(0, height, 0, 2 * height, 0xff000000, 0x00000000, Shader.TileMode.CLAMP));
}
 
开发者ID:FreeSunny,项目名称:Amazing,代码行数:20,代码来源:FadingPic.java

示例6: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    //init the value
    borderWidth = 0;
    borderColor = 0xddffffff;
    pressAlpha = 0x42;
    pressColor = 0x42000000;
    radius = 16;
    shapeType = 0;

    // get attribute of EaseImageView
    if (attrs != null) {
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.EaseImageView);
        borderColor = array.getColor(R.styleable.EaseImageView_ease_border_color, borderColor);
        borderWidth = array.getDimensionPixelOffset(R.styleable.EaseImageView_ease_border_width, borderWidth);
        pressAlpha = array.getInteger(R.styleable.EaseImageView_ease_press_alpha, pressAlpha);
        pressColor = array.getColor(R.styleable.EaseImageView_ease_press_color, pressColor);
        radius = array.getDimensionPixelOffset(R.styleable.EaseImageView_ease_radius, radius);
        shapeType = array.getInteger(R.styleable.EaseImageView_ease_shape_type, shapeType);
        array.recycle();
    }

    // set paint when pressed
    pressPaint = new Paint();
    pressPaint.setAntiAlias(true);
    pressPaint.setStyle(Paint.Style.FILL);
    pressPaint.setColor(pressColor);
    pressPaint.setAlpha(0);
    pressPaint.setFlags(Paint.ANTI_ALIAS_FLAG);

    setDrawingCacheEnabled(true);
    setWillNotDraw(false);
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:33,代码来源:EaseImageView.java

示例7: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init() {

        colorPointerPaint = new Paint();
        colorPointerPaint.setStyle(Style.STROKE);
        colorPointerPaint.setStrokeWidth(2f);
        colorPointerPaint.setARGB(128, 0, 0, 0);

        valuePointerPaint = new Paint();
        valuePointerPaint.setStyle(Style.STROKE);
        valuePointerPaint.setStrokeWidth(2f);

        valuePointerArrowPaint = new Paint();

        colorWheelPaint = new Paint();
        colorWheelPaint.setAntiAlias(true);
        colorWheelPaint.setDither(true);

        valueSliderPaint = new Paint();
        valueSliderPaint.setAntiAlias(true);
        valueSliderPaint.setDither(true);

        colorViewPaint = new Paint();
        colorViewPaint.setAntiAlias(true);

        colorViewPath = new Path();
        valueSliderPath = new Path();
        arrowPointerPath = new Path();

        outerWheelRect = new RectF();
        innerWheelRect = new RectF();

        colorPointerCoords = new RectF();

    }
 
开发者ID:MLNO,项目名称:airgram,代码行数:35,代码来源:MultiColorPicker.java

示例8: drawBackground

import android.graphics.Paint; //导入方法依赖的package包/类
public void drawBackground(Canvas canvas, Paint paint) {
    canvas.save();
    canvas.translate(getOffsetX(), getOffsetY());
    paint.reset();
    paint.setStyle(Paint.Style.FILL);//充满
    paint.setColor(Color.LTGRAY);
    paint.setAntiAlias(true);
    paint.setAlpha(100);
    RectF oval3 = new RectF(0, 0, mBackground.previewSize, mBackground.previewSize);
    canvas.drawRoundRect(oval3, 40, 40,paint);
    canvas.restore();

}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:14,代码来源:FolderIcon.java

示例9: transform

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
public Bitmap transform(Bitmap source) {
    int size = Math.min(source.getWidth(), source.getHeight());

    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;

    Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
    if (squaredBitmap != source) {
        source.recycle();
    }

    Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());

    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP,
            BitmapShader.TileMode.CLAMP);
    paint.setShader(shader);
    paint.setAntiAlias(true);

    float r = size / 2f;
    canvas.drawCircle(r, r, r, paint);

    squaredBitmap.recycle();
    return bitmap;
}
 
开发者ID:lurbas,项目名称:ListItemView,代码行数:28,代码来源:CircleTransform.java

示例10: drawDrawable

import android.graphics.Paint; //导入方法依赖的package包/类
/**
 * draw Rounded Rectangle
 *
 * @param canvas
 * @param bitmap
 */
private void drawDrawable(Canvas canvas, Bitmap bitmap) {
    Paint paint = new Paint();
    paint.setColor(0xffffffff);
    paint.setAntiAlias(true); //smooths out the edges of what is being drawn
    PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.SRC_IN);
    // set flags
    int saveFlags = Canvas.MATRIX_SAVE_FLAG
            | Canvas.CLIP_SAVE_FLAG
            | Canvas.HAS_ALPHA_LAYER_SAVE_FLAG
            | Canvas.FULL_COLOR_LAYER_SAVE_FLAG
            | Canvas.CLIP_TO_LAYER_SAVE_FLAG;
    canvas.saveLayer(0, 0, width, height, null, saveFlags);

    if (shapeType == 1) {
        canvas.drawCircle(width / 2, height / 2, width / 2 - 1, paint);
    } else if (shapeType == 2) {
        RectF rectf = new RectF(1, 1, getWidth() - 1, getHeight() - 1);
        canvas.drawRoundRect(rectf, radius + 1, radius + 1, paint);
    }

    paint.setXfermode(xfermode);

    float scaleWidth = ((float) getWidth()) / bitmap.getWidth();
    float scaleHeight = ((float) getHeight()) / bitmap.getHeight();

    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);

    //bitmap scale
    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);

    canvas.drawBitmap(bitmap, 0, 0, paint);
    canvas.restore();
}
 
开发者ID:turoDog,项目名称:KTalk,代码行数:41,代码来源:EaseImageView.java

示例11: MulRingProgressBar

import android.graphics.Paint; //导入方法依赖的package包/类
public MulRingProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.context = context;
    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.MulRingProgressBar);
    mBallColor = typedArray.getColor(R.styleable.MulRingProgressBar_progress_ball_color, mBallColor);
    mRingColor = typedArray.getColor(R.styleable.MulRingProgressBar_progress_ring_color, mRingColor);
    mBallRadius = typedArray.getDimension(R.styleable.MulRingProgressBar_progress_ball_radius, mBallRadius);
    mRingRadius = typedArray.getDimension(R.styleable.MulRingProgressBar_progress_ring_radius, mRingRadius);
    mDuration = typedArray.getInteger(R.styleable.MulRingProgressBar_progress_duration, mDuration);
    increment = typedArray.getFloat(R.styleable.MulRingProgressBar_progress_increment, increment);
    mCount = typedArray.getInteger(R.styleable.MulRingProgressBar_progress_count, mCount);
    typedArray.recycle();

    mList = new ArrayList<>();

    for (int i = mCount; i > 0; i--) {
        ProgressBean pb = new ProgressBean();
        pb.setmCurrentAngle(0);
        pb.setmBallRadius(mBallRadius + increment * i);
        pb.setDuration(mDuration - (mCount - i) * delay);
        pb.setAnimator(initAnimatior(pb));
        mList.add(pb);
    }

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.FILL_AND_STROKE);


}
 
开发者ID:yanyiqun001,项目名称:goRefresh,代码行数:31,代码来源:MulRingProgressBar.java

示例12: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init() {
    paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setAntiAlias(true);
    paint.setTextSize(48.0f);
    paint.setTextAlign(Paint.Align.CENTER);
}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:8,代码来源:TGPopwindowView.java

示例13: CubeEngine

import android.graphics.Paint; //导入方法依赖的package包/类
CubeEngine() {
    // Create a Paint to draw the lines for our cube
    final Paint paint = mPaint;
    paint.setColor(0xffffffff);
    paint.setAntiAlias(true);
    paint.setStrokeWidth(2);
    paint.setStrokeCap(Paint.Cap.ROUND);
    paint.setStyle(Paint.Style.STROKE);

    mStartTime = SystemClock.elapsedRealtime();

    mPrefs = CubeWallpaper2.this.getSharedPreferences(SHARED_PREFS_NAME, 0);
    mPrefs.registerOnSharedPreferenceChangeListener(this);
    onSharedPreferenceChanged(mPrefs, null);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:16,代码来源:CubeWallpaper2.java

示例14: drawHistoryPoint

import android.graphics.Paint; //导入方法依赖的package包/类
private void drawHistoryPoint(final Canvas canvas, final float startX, final float startY) {
  final Paint p = new Paint();
  p.setAntiAlias(false);
  p.setTypeface(Typeface.SERIF);

  p.setColor(Color.RED);
  p.setStrokeWidth(2.0f);

  // Draw the center circle.
  p.setColor(Color.GREEN);
  canvas.drawCircle(startX, startY, 3.0f, p);

  p.setColor(Color.RED);

  // Iterate through in backwards order.
  synchronized (debugHistory) {
    final int numPoints = debugHistory.size();
    float lastX = startX;
    float lastY = startY;
    for (int keypointNum = 0; keypointNum < numPoints; ++keypointNum) {
      final PointF delta = debugHistory.get(numPoints - keypointNum - 1);
      final float newX = lastX + delta.x;
      final float newY = lastY + delta.y;
      canvas.drawLine(lastX, lastY, newX, newY, p);
      lastX = newX;
      lastY = newY;
    }
  }
}
 
开发者ID:apacha,项目名称:TensorflowAndroidDemo,代码行数:30,代码来源:ObjectTracker.java

示例15: init

import android.graphics.Paint; //导入方法依赖的package包/类
private void init(){
    backgroundPaint = new Paint();
    backgroundPaint.setColor(0x66000000);
    backgroundPaint.setStyle(Paint.Style.FILL);

    wavepaint = new Paint();
    wavepaint.setColor(0xff3F51B5);
    wavepaint.setAntiAlias(true);
    wavepaint.setStyle(Paint.Style.FILL);
}
 
开发者ID:raj10071997,项目名称:Alexa-Voice-Service,代码行数:11,代码来源:recorderView.java


注:本文中的android.graphics.Paint.setAntiAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。