Android PaintFlagsDrawFilter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android PaintFlagsDrawFilter class.

This code example shows how to use the following methods:
            mMediumPaint.setColor(0xff000000);
            mMediumPaint.setFakeBoldText(true);
            mMediumPaint.setTextSize(24.0f);
 
            mDrawFilter = new PaintFlagsDrawFilter(
                    Paint.FAKE_BOLD_TEXT_FLAG, Paint.UNDERLINE_TEXT_FLAG);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(255, 255, 255);
 
            canvas.setDrawFilter(null);
            canvas.drawText("Hello OpenGL renderer!", 100, 120, mMediumPaint);
            canvas.setDrawFilter(mDrawFilter);
            canvas.drawText("Hello OpenGL renderer!", 100, 220, mMediumPaint);
        } 
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0.2f);
 
        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
 
    public Drawable createIconDrawable(Drawable src) {
        Bitmap scaled = createIconBitmap(src);
 
        StateListDrawable result = new StateListDrawable();
 
        result.addState(new int[] { android.R.attr.state_focused },
                new BitmapDrawable(createSelectedBitmap(scaled, false)));
        result.addState(new int[] { android.R.attr.state_pressed },
                new BitmapDrawable(createSelectedBitmap(scaled, true)));
        result.addState(new int[0], new BitmapDrawable(scaled));
 
        result.setBounds(0, 0, mIconTextureWidth, mIconTextureHeight);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    private static final Rect sOldBounds = new Rect();
    private static Canvas sCanvas = new Canvas();
 
    static { 
        sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
 
    /** 
     * Returns a Drawable representing the thumbnail of the specified Drawable. 
     * The size of the thumbnail is defined by the dimension 
     * android.R.dimen.launcher_application_icon_size. 
     * 
     * This method is not thread-safe and should be invoked on the UI thread only. 
     * 
     * @param icon The icon to get a thumbnail of. 
     * @param context The application's context. 
     * 
     * @return A thumbnail for the specified icon or the icon itself if the 
     *         thumbnail could not be created.  
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0.2f);
 
        mCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
 
    public Drawable createIconDrawable(Drawable src) {
        Bitmap scaled = createIconBitmap(src);
 
        StateListDrawable result = new StateListDrawable();
 
        result.addState(new int[] { android.R.attr.state_focused },
                new BitmapDrawable(createSelectedBitmap(scaled, false)));
        result.addState(new int[] { android.R.attr.state_pressed },
                new BitmapDrawable(createSelectedBitmap(scaled, true)));
        result.addState(new int[0], new BitmapDrawable(scaled));
 
        result.setBounds(0, 0, mIconTextureWidth, mIconTextureHeight);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
	@Override 
	public void onAttachedToWindow() { 
		compassArrow = BitmapFactory.decodeResource(context.getResources(), arrowSkin);
 
		setfil = new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG);
		remfil = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0);
	} 
 
	@Override 
	public void onDetachedFromWindow() { 
		if (compassArrow != null) {
			compassArrow.recycle();
			compassArrow = null;
		} 
	} 
	 
	public void setContent(cgBase baseIn, Double cacheLatIn, Double cacheLonIn) {
		base = baseIn;
		cacheLat = cacheLatIn;
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    private static final Rect sOldBounds = new Rect();
    private static final Canvas sCanvas = new Canvas();
 
    static { 
        sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
    static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff };
    static int sColorIndex = 0;
 
    /** 
     * Returns a bitmap suitable for the all apps view. Used to convert pre-ICS 
     * icon bitmaps that are stored in the database (which were 74x74 pixels at hdpi size) 
     * to the proper size (48dp) 
     */ 
    static Bitmap createIconBitmap(Bitmap icon, Context context) {
        int textureWidth = sIconTextureWidth;
        int textureHeight = sIconTextureHeight;
        int sourceWidth = icon.getWidth();
        int sourceHeight = icon.getHeight();
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
            mMediumPaint.setColor(0xff000000);
            mMediumPaint.setFakeBoldText(true);
            mMediumPaint.setTextSize(24.0f);
 
            mDrawFilter = new PaintFlagsDrawFilter(
                    Paint.FAKE_BOLD_TEXT_FLAG, Paint.UNDERLINE_TEXT_FLAG);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(255, 255, 255);
 
            canvas.setDrawFilter(null);
            canvas.drawText("Hello OpenGL renderer!", 100, 120, mMediumPaint);
            canvas.setDrawFilter(mDrawFilter);
            canvas.drawText("Hello OpenGL renderer!", 100, 220, mMediumPaint);
        } 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    private static final Rect sOldBounds = new Rect();
    private static Canvas sCanvas = new Canvas();
 
    static { 
        sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
 
    /** 
     * Returns a Drawable representing the thumbnail of the specified Drawable. 
     * The size of the thumbnail is defined by the dimension 
     * android.R.dimen.launcher_application_icon_size. 
     * 
     * This method is not thread-safe and should be invoked on the UI thread only. 
     * 
     * @param icon The icon to get a thumbnail of. 
     * @param context The application's context. 
     * 
     * @return A thumbnail for the specified icon or the icon itself if the 
     *         thumbnail could not be created.  
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
             
        int canvasWidth, canvasHeight;
        int bitmapWidth = mBitmap.getWidth();
        int bitmapHeight = mBitmap.getHeight();
             
        canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG, Paint.FILTER_BITMAP_FLAG));
        canvasWidth = width;
        canvasHeight = height;
             
        if (canvasWidth < bitmapWidth && canvasHeight < bitmapWidth) {
            // キャンバスより大きかったら長い辺をキャンバスサイズに合わせてリサイズする 
            float ratio = bitmapWidth < bitmapHeight ? (float)width / (float)bitmapWidth : (float)height / (float)bitmapHeight;
            Bitmap bitmap = Bitmap.createScaledBitmap(mBitmap, (int)(bitmapWidth * ratio), (int)(bitmapHeight * ratio), true);
            recycle(); 
            bitmapWidth = bitmap.getWidth();
            bitmapHeight = bitmap.getHeight();
            mBitmap = bitmap;
        } 
             
        if (bitmapWidth > canvasWidth || bitmapHeight > canvasHeight) {
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
    private static final Rect sOldBounds = new Rect();
    private static final Canvas sCanvas = new Canvas();
 
    static { 
        sCanvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.DITHER_FLAG,
                Paint.FILTER_BITMAP_FLAG));
    } 
    static int sColors[] = { 0xffff0000, 0xff00ff00, 0xff0000ff };
    static int sColorIndex = 0;
 
    /** 
     * Returns a bitmap suitable for the all apps view. Used to convert pre-ICS 
     * icon bitmaps that are stored in the database (which were 74x74 pixels at hdpi size) 
     * to the proper size (48dp) 
     */ 
    static Bitmap createIconBitmap(Bitmap icon, Context context) {
        int textureWidth = sIconTextureWidth;
        int textureHeight = sIconTextureHeight;
        int sourceWidth = icon.getWidth();
        int sourceHeight = icon.getHeight();
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android PaintFlagsDrawFilter Questions & Answers:

See Code Examples for Android PaintFlagsDrawFilter Methods: