本文整理汇总了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);
}
示例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();
}
示例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();
}
示例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);
}
};
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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<>();
}
示例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));
}
示例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;
}
示例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();
}
示例15: MyView
public MyView(Context c) {
super(c);
context = c;
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
}