當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。