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


Java Paint.DITHER_FLAG属性代码示例

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


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

示例1: DrawingView

public DrawingView(Context context) {
    super(context);
    mContext=context;
    mPath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(Color.GREEN);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(12);
    circlePaint = new Paint();
    circlePath = new Path();
    circlePaint.setAntiAlias(true);
    circlePaint.setColor(Color.BLUE);
    circlePaint.setStyle(Paint.Style.STROKE);
    circlePaint.setStrokeJoin(Paint.Join.MITER);
    circlePaint.setStrokeWidth(4f);
}
 
开发者ID:kinemic,项目名称:kinemic-example-android,代码行数:21,代码来源:DrawingView.java

示例2: init

private void init() {
    bgPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    bgPaint.setStyle(Paint.Style.STROKE);
    bgPaint.setStrokeWidth(borderWidth);

    pgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    pgPaint.setStyle(Paint.Style.FILL);

    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setTextSize(textSize);

    textRect = new Rect();
    bgRectf = new RectF(borderWidth, borderWidth, getMeasuredWidth() - borderWidth, getMeasuredHeight() - borderWidth);

    if(isStop){
        progressColor = stopColor;
    } else{
        progressColor = loadingColor;
    }

    flikerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.flicker);
    flickerLeft = -flikerBitmap.getWidth();

    initPgBimap();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:FlikerProgressBar.java

示例3: BitmapAnimationBackend

public BitmapAnimationBackend(
    PlatformBitmapFactory platformBitmapFactory,
    BitmapFrameCache bitmapFrameCache,
    AnimationInformation animationInformation,
    BitmapFrameRenderer bitmapFrameRenderer,
    @Nullable BitmapFramePreparationStrategy bitmapFramePreparationStrategy,
    @Nullable BitmapFramePreparer bitmapFramePreparer) {
  mPlatformBitmapFactory = platformBitmapFactory;
  mBitmapFrameCache = bitmapFrameCache;
  mAnimationInformation = animationInformation;
  mBitmapFrameRenderer = bitmapFrameRenderer;
  mBitmapFramePreparationStrategy = bitmapFramePreparationStrategy;
  mBitmapFramePreparer = bitmapFramePreparer;

  mPaint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
  updateBitmapDimensions();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:BitmapAnimationBackend.java

示例4: CustomShadow

public CustomShadow(
        Resources resources, int backgroundColor, float radius,
        float shadowSize, float maxShadowSize
) {
    mShadowStartColor = resources.getColor(R.color.cardview_shadow_start_color);
    mShadowEndColor = resources.getColor(R.color.cardview_shadow_end_color);
    mInsetShadow = resources.getDimensionPixelSize(R.dimen.cardview_compat_inset_shadow);
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setColor(backgroundColor);
    mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mCornerShadowPaint.setStyle(Paint.Style.FILL);
    mCornerRadius = (int) (radius + .5f);
    mCardBounds = new RectF();
    mEdgeShadowPaint = new Paint(mCornerShadowPaint);
    mEdgeShadowPaint.setAntiAlias(false);
    setShadowSize(shadowSize, maxShadowSize);

    CustomShadow.sRoundRectHelper = new CustomShadow.RoundRectHelper() {
        @Override
        public void drawRoundRect(Canvas canvas, RectF bounds, float cornerRadius,
                                  Paint paint) {
            canvas.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
        }
    };
}
 
开发者ID:florent37,项目名称:Depth,代码行数:25,代码来源:CustomShadow.java

示例5: 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;

    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;
}
 
开发者ID:nichbar,项目名称:Aequorea,代码行数:23,代码来源:CircleTransformation.java

示例6: ShadowDrawableWrapper

public ShadowDrawableWrapper(Context context, Drawable content, float radius,
          float shadowSize, float maxShadowSize) {
  super(content);

  mShadowStartColor = ContextCompat.getColor(context, R.color.design_fab_shadow_start_color);
  mShadowMiddleColor = ContextCompat.getColor(context, R.color.design_fab_shadow_mid_color);
  mShadowEndColor = ContextCompat.getColor(context, R.color.design_fab_shadow_end_color);

  mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  mCornerShadowPaint.setStyle(Paint.Style.FILL);
  mCornerRadius = Math.round(radius);
  mContentBounds = new RectF();
  mEdgeShadowPaint = new Paint(mCornerShadowPaint);
  mEdgeShadowPaint.setAntiAlias(false);
  setShadowSize(shadowSize, maxShadowSize);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:16,代码来源:ShadowDrawableWrapper.java

示例7: RoundRectDrawableWithShadow

public RoundRectDrawableWithShadow(int backgroundColor, float radius,
                                   float shadowSize, float maxShadowSize) {
    if(DEBUG) Log.d(getClass().getSimpleName(), "RoundRectDrawableWithShadow("+radius+","+shadowSize+","+maxShadowSize+")");

    mInsetShadow = ViewUtils.dpToPx(SHADOW_INSET_DP);
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setColor(backgroundColor);
    mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mCornerShadowPaint.setStyle(Paint.Style.FILL);
    mCornerRadius = (int) (radius + .5f);
    mCardBounds = new RectF();
    mEdgeShadowPaint = new Paint(mCornerShadowPaint);
    mEdgeShadowPaint.setAntiAlias(false);
    if(DEBUG) {
        mBoundsPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
        mBoundsPaint.setColor(Color.BLACK);
        mBoundsPaint.setStyle(Paint.Style.STROKE);
        mBoundsPaint.setStrokeWidth(1);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(1);
        mCornerShadowPaint.setStrokeWidth(1);
    }
    setShadow(TOP|LEFT|RIGHT|BOTTOM);
    setShadowSize(shadowSize, maxShadowSize);
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:25,代码来源:RoundRectDrawableWithShadow.java

示例8: resizeAndCropCenter

public static Bitmap resizeAndCropCenter(Bitmap bitmap, int size, boolean recycle) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    if (w == size && h == size) return bitmap;

    // scale the image so that the shorter side equals to the target;
    // the longer side will be center-cropped.
    float scale = (float) size / Math.min(w,  h);

    Bitmap target = Bitmap.createBitmap(size, size, getConfig(bitmap));
    int width = Math.round(scale * bitmap.getWidth());
    int height = Math.round(scale * bitmap.getHeight());
    Canvas canvas = new Canvas(target);
    canvas.translate((size - width) / 2f, (size - height) / 2f);
    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;
}
 
开发者ID:mayurkaul,项目名称:medialibrary,代码行数:20,代码来源:BitmapUtils.java

示例9: RoundRectDrawableWithShadow

RoundRectDrawableWithShadow(Resources resources, int backgroundColor, float radius,
        float shadowSize, float maxShadowSize) {
    mShadowStartColor = resources.getColor(R.color.cardview_shadow_start_color);
    mShadowEndColor = resources.getColor(R.color.cardview_shadow_end_color);
    mInsetShadow = resources.getDimensionPixelSize(R.dimen.cardview_compat_inset_shadow);
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setColor(backgroundColor);
    mCornerShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mCornerShadowPaint.setStyle(Paint.Style.FILL);
    mCornerRadius = (int) (radius + .5f);
    mCardBounds = new RectF();
    mEdgeShadowPaint = new Paint(mCornerShadowPaint);
    mEdgeShadowPaint.setAntiAlias(false);
    setShadowSize(shadowSize, maxShadowSize);
}
 
开发者ID:stytooldex,项目名称:pius1,代码行数:15,代码来源:RoundRectDrawableWithShadow.java

示例10: initView

/**
 * Inits paint objects and default values.
 */
private void initView() {
    starPath = new Path();
    cornerPathEffect = new CornerPathEffect(starCornerRadius);

    paintStarOutline = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarOutline.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarOutline.setAntiAlias(true);
    paintStarOutline.setDither(true);
    paintStarOutline.setStrokeJoin(Paint.Join.ROUND);
    paintStarOutline.setStrokeCap(Paint.Cap.ROUND);
    paintStarOutline.setColor(Color.BLACK);
    paintStarOutline.setPathEffect(cornerPathEffect);

    paintStarBorder = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarBorder.setStyle(Paint.Style.STROKE);
    paintStarBorder.setStrokeJoin(Paint.Join.ROUND);
    paintStarBorder.setStrokeCap(Paint.Cap.ROUND);
    paintStarBorder.setStrokeWidth(starBorderWidth);
    paintStarBorder.setPathEffect(cornerPathEffect);

    paintStarBackground = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarBackground.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarBackground.setAntiAlias(true);
    paintStarBackground.setDither(true);
    paintStarBackground.setStrokeJoin(Paint.Join.ROUND);
    paintStarBackground.setStrokeCap(Paint.Cap.ROUND);

    paintStarFill = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paintStarFill.setStyle(Paint.Style.FILL_AND_STROKE);
    paintStarFill.setAntiAlias(true);
    paintStarFill.setDither(true);
    paintStarFill.setStrokeJoin(Paint.Join.ROUND);
    paintStarFill.setStrokeCap(Paint.Cap.ROUND);

    defaultStarSize = applyDimension(COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:39,代码来源:SimpleRatingBar.java

示例11: init

/***
 * 初始化
 */
private void init() {
    //关闭硬件加速
    //否则橡皮擦模式下,设置的 PorterDuff.Mode.CLEAR ,实时绘制的轨迹是黑色
    setBackgroundColor(Color.WHITE);//设置白色背景
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    //画笔
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setStrokeWidth(4f);
    mPaint.setAntiAlias(true);
    mPaint.setColor(Color.BLACK);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);//使画笔更加圆润
    mPaint.setStrokeCap(Paint.Cap.ROUND);//同上
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);
    //保存签名的画布
    post(new Runnable() {//拿到控件的宽和高
        @Override
        public void run() {
            //获取PaintView的宽和高
            //由于橡皮擦使用的是 Color.TRANSPARENT ,不能使用RGB-565
            mBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_4444);
            mCanvas = new Canvas(mBitmap);
            //抗锯齿
            mCanvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
            //背景色
            mCanvas.drawColor(Color.WHITE);
        }
    });

    undoList = new LinkedList<>();
    redoList = new LinkedList<>();
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:35,代码来源:PaintView.java

示例12: init

private void init() {
  mPath = new Path();
  mBitmapPaint = new Paint(Paint.DITHER_FLAG);
  mPaint = new Paint();
  mPaint.setAntiAlias(true);
  mPaint.setDither(true);
  mPaint.setColor(Color.WHITE);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeJoin(Paint.Join.ROUND);
  mPaint.setStrokeCap(Paint.Cap.ROUND);
  mPaint.setStrokeWidth(mPenSize);
  mDrawMode = true;
  mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN));
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:14,代码来源:DrawingView.java

示例13: createBitmap

private Bitmap createBitmap(int x, int y, int w, int h) {
    Bitmap newBimap = delegate.getBitmap();
    if (newBimap != null) {
        bitmapToEdit = newBimap;
    }

    Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);

    Matrix matrix = new Matrix();
    matrix.setTranslate(-bitmapToEdit.getWidth() / 2, -bitmapToEdit.getHeight() / 2);
    matrix.postRotate(orientation);
    if (orientation % 360 == 90 || orientation % 360 == 270) {
        matrix.postTranslate(bitmapToEdit.getHeight() / 2 - x, bitmapToEdit.getWidth() / 2 - y);
    } else {
        matrix.postTranslate(bitmapToEdit.getWidth() / 2 - x, bitmapToEdit.getHeight() / 2 - y);
    }
    canvas.drawBitmap(bitmapToEdit, matrix, paint);
    try {
        canvas.setBitmap(null);
    } catch (Exception e) {
        //don't promt, this will crash on 2.x
    }

    return bitmap;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:27,代码来源:PhotoCropView.java

示例14: ChatMessageDrawable

public ChatMessageDrawable(int backgroundColor, float radius) {
    mRadius = radius;
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    mPaint.setColor(backgroundColor);
    mBoundsF = new RectF();
    mBoundsI = new Rect();
}
 
开发者ID:susiai,项目名称:susi_android_v1,代码行数:7,代码来源:ChatMessageDrawable.java

示例15: MyView

public MyView(Context c) {
    super(c);
    context = c;
    mPath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);

}
 
开发者ID:feup-infolab,项目名称:labtablet,代码行数:7,代码来源:FingerPaintActivity.java


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