Paint setDither - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Paint setDither method.

This code example shows how to use the following methods:setAntiAlias, setColor, setDither, setFilterBitmap
            radius = r;
        } 
    } 
 
    public PointCloud(Drawable drawable) {
        mPaint = new Paint();
        mPaint.setFilterBitmap(true);
        mPaint.setColor(Color.rgb(255, 255, 255)); // TODO: make configurable
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
 
        mDrawable = drawable;
        if (mDrawable != null) {
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        } 
    } 
 
    public void setCenter(float x, float y) {
        mCenterX = x;
        mCenterY = y;
9
CodeRank
This code example shows how to use the following methods:setColor, setDither, setFilterBitmap, setStrokeWidth, setStyle
	 * @param radius 
	 *           the radius 
	 */ 
	public PreviewCircleDrawable( final float radius ) {
 
		mPaint = new Paint( Paint.ANTI_ALIAS_FLAG );
		mPaint.setFilterBitmap( false );
		mPaint.setDither( true );
		mPaint.setStrokeWidth( 10.0f );
		mPaint.setStyle( Paint.Style.STROKE );
		mPaint.setColor( Color.WHITE );
		mRadius = radius;
	} 
 
	/** 
	 * Sets the paint. 
	 *  
	 * @param value 
	 *           the new paint 
	 */ 
8
CodeRank
This code example shows how to use the following methods:setDither, setFilterBitmap
	protected Bitmap mBitmap;
	protected Paint mPaint;
 
	public FastBitmapDrawable(final Bitmap b) {
		mBitmap = b;
		mPaint = new Paint();
		mPaint.setDither(true);
		mPaint.setFilterBitmap(true);
	} 
 
	public FastBitmapDrawable(final Resources res, final InputStream is) {
		this(BitmapFactory.decodeStream(is));
	} 
 
	@Override 
	public void draw(final Canvas canvas) {
		canvas.drawBitmap(mBitmap, 0.0f, 0.0f, mPaint);
	} 
 
	@Override 
7
CodeRank
This code example shows how to use the following methods:setColorFilter, setDither, setFilterBitmap
        Bitmap filtered = Bitmap.createBitmap(in, cropWidth, cropHeight, Bitmap.Config.ARGB_8888);
 
        // Composite the bitmap scaled to the target size and darken the pixels. 
        Bitmap output = Bitmap.createBitmap(destWidth, destHeight, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(output);
        Paint paint = new Paint();
        paint.setFilterBitmap(true);
        paint.setDither(true);
        paint.setColorFilter(new LightingColorFilter(MULTIPLY_COLOR, 0));
        canvas.scale(scale, scale);
        canvas.drawBitmap(filtered, 0f, 0f, paint);
        filtered.recycle();
 
        // Clear the texture 
        mBaseTexture = null;
        return output;
    } 
 
    private static void boxBlurFilter(int[] in, int[] out, int width, int height, int startFadeX) {
        int inPos = 0;
7
CodeRank
This code example shows how to use the following methods:setAntiAlias, setDither, setFilterBitmap, setSubpixelText, setTypeface
 
	public ExternalFilterPackDrawable( String title, String shortTitle, int numEffects, int color, Typeface typeFace, Bitmap shadow,
			Bitmap effect ) {
		super(); 
		mMatrix = new Matrix();
		mPaint = new Paint( Paint.ANTI_ALIAS_FLAG );
		mPaint.setSubpixelText( true );
		mPaint.setAntiAlias( true );
		mPaint.setDither( true );
		mPaint.setFilterBitmap( true );
 
		bitmapWidth = effect.getWidth();
		bitmapHeight = effect.getHeight();
 
		Log.d( "xxx", "size: " + bitmapWidth + "x" + bitmapHeight );
 
		xRatio = (float) defaultWidth / bitmapWidth;
		yRatio = (float) defaultHeight / bitmapHeight;
 
		mShadowBitmap = new WeakReference<Bitmap>( shadow );

8
CodeRank
This code example shows how to use the following methods:setAlpha, setColorFilter, setDither, setShader
	@Override 
	public void draw( Canvas canvas ) {
 
		if ( !ensureValidRect() ) return; 
 
		mFillPaint.setAlpha( mAlpha );
		mFillPaint.setDither( mDither );
		mFillPaint.setColorFilter( mColorFilter );
 
		if ( mCornerRadius > 0 ) {
			float rad = mCornerRadius;
			float r = Math.min( mRect.width(), mRect.height() ) * 0.5f;
			if ( rad > r ) {
				rad = r;
			} 
			canvas.drawRoundRect( mRect, rad, rad, mFillPaint );
		} else { 
			canvas.drawRect( mRect, mFillPaint );
		} 
 

7
CodeRank
This code example shows how to use the following methods:setAntiAlias, setColor, setDither, setFilterBitmap
            radius = r;
        } 
    } 
 
    public PointCloud(Drawable drawable) {
        mPaint = new Paint();
        mPaint.setFilterBitmap(true);
        mPaint.setColor(Color.rgb(255, 255, 255)); // TODO: make configurable
        mPaint.setAntiAlias(true);
        mPaint.setDither(true);
 
        mDrawable = drawable;
        if (mDrawable != null) {
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        } 
    } 
 
    public void setCenter(float x, float y) {
        mCenterX = x;
        mCenterY = y;
7
CodeRank
This code example shows how to use the following methods:setDither
    } 
 
    @Override 
    public void setDither(boolean dither) {
        mStartPaint.setDither(true);
        mEndPaint.setDither(true);
    } 
 
    @Override 
    public void setFilterBitmap(boolean filter) {
        mStartPaint.setFilterBitmap(true);
        mEndPaint.setFilterBitmap(true);
    } 
 
    /** 
     * Ignored. 
     */ 
    public void setAlpha(int alpha) {
    } 
 
7
CodeRank
This code example shows how to use the following methods:setDither, setFilterBitmap
			mIntrinsicHeight = mBitmap.getHeight();
		} else { 
			mIntrinsicWidth = 0;
			mIntrinsicHeight = 0;
		} 
		mPaint = new Paint();
		mPaint.setDither( true );
		mPaint.setFilterBitmap( true );
	} 
	 
	public void setBitmap( Bitmap bitmap ) {
		mBitmap = bitmap;
	} 
	 
	public FastBitmapDrawable( Resources res, InputStream is ){
		this(BitmapFactory.decodeStream(is));
	} 
 
	@Override 
	public void draw( Canvas canvas ) {
7
CodeRank
This code example shows how to use the following methods:setAntiAlias, setDither, setPathEffect, setStrokeCap, setStrokeJoin
            return false; 
        } 
         
        this.mCanvas = canvas;
         
        mPen.setAntiAlias(true);            // 线条反走样
        mPen.setDither(true);               // 高精度颜色采样,会略慢
        mPen.setStyle(Paint.Style.STROKE);  // 仅描边
        mPen.setPathEffect(null);           // 实线
        mPen.setStrokeCap(Paint.Cap.ROUND); // 圆端
        mPen.setStrokeJoin(Paint.Join.ROUND); // 折线转角圆弧过渡
        mBrush.setStyle(Paint.Style.FILL);  // 仅填充
        mBrush.setColor(Color.TRANSPARENT); // 默认透明,不填充
        mBrush.setAntiAlias(true);          // 文字反走样
         
        return true; 
    } 
     
    public void endPaint() { 
        this.mCanvas = null;
7
CodeRank

Related Paint setDither Questions & Answers:

setDither Method Overview
Helper for setFlags(), setting or clearing the DITHER_FLAG bit Dithering affects how colors that are higher precision than the device are down-sampled.
See Code Examples for other Android Paint Methods: