Code example for Canvas

Methods: drawColorrestoresavesetBitmap

0
    private Bitmap createOriginalImage(ImageView v, Canvas canvas) {
        final Drawable d = v.getDrawable();
        final Bitmap b = Bitmap.createBitmap(
                d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
 
        canvas.setBitmap(b);
        canvas.save();
            d.draw(canvas);
        canvas.restore();
        canvas.setBitmap(null);
 
        return b;
    } 
 
    /** 
     * Creates a new press state image which is the old image with a blue overlay. 
     * Responsibility for the bitmap is transferred to the caller. 
     */ 
    private Bitmap createPressImage(ImageView v, Canvas canvas) {
        final Drawable d = v.getDrawable();
        final Bitmap b = Bitmap.createBitmap(
                d.getIntrinsicWidth(), d.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
 
        canvas.setBitmap(b);
        canvas.save();
            d.draw(canvas);
        canvas.restore();
        canvas.drawColor(mHighlightColor, PorterDuff.Mode.SRC_IN);
        canvas.setBitmap(null);
 
        return b;
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java