Question: Just wondering what the fastest way is to draw a bitmap to canvas?

Currently I have a bitmap (and canvas for drawing) which i use to double buffer drawing calls, and then when i draw to canvas have a scrolling effect by applying a 1px canvas translation. This alone will reduce the framerate from 60+ FPS to ~40, quite a hit. Im not using surfaceView (or GLSurfaceView) at the moment but just wondering if im missing anything that would improve the speed. onDraw() code below

```
@Override
    public void onDraw(Canvas canvas)
    {
        //update fps text
        mFpsTracker.frameTouch();

        if(mBufferedBitmap == null)
        {
            mBufferedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_4444);
            mBufferedCanvas = new Canvas(mBufferedBitmap);
        }

        paint.setColor(Color.BLUE);
        mBufferedCanvas.drawLine(0, getHeight(), getWidth(), getHeight(), paint);
        mBufferedCanvas.translate(0, -1);

    canvas.drawBitmap(mBufferedBitmap, 0, 0, null); 

    //draw fps
    mTextPaint.setColor(Color.WHITE);
    canvas.drawText(mFpsTracker.getFPSString(), 40, 40, mTextPaint);

    invalidate();       
}

```

Answer: 
please see [this](http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/) blog post by Romain Guy.

A video version is available [here](http://www.youtube.com/watch?v=duefsFTJXzc&t=25m0s).

Don't use ARGB\_4444 anymore. It is deprecated. Each pixel is only allocated 4 bits per channel (hence the name). ARBG\_8888 offers 16,777,216 colors instead of ARBG\_4444's 4,096, but uses 4 bytes per pixel instead of 2.

In Gingerbread, Android made ARGB\_8888 the standard format for [Surface](http://developer.android.com/reference/android/view/Surface.html) and increased memory allotment per process because of it.

It is more efficient to set your [Window's](http://developer.android.com/reference/android/view/Window.html#setFormat%28int%29) and (assuming you are using streamlined [SurfaceView](http://developer.android.com/reference/android/view/SurfaceView.html)) SurfaceHolder's format to [RGBA\_8888](http://developer.android.com/reference/android/graphics/PixelFormat.html#RGBA_8888). This avoids format changes which are noticeably slower.

Other tips include:

* Limit alpha compositing, as this requires comparatively expensive blending from Skia.
* Request Bitmap [Options](http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html) that prefer the ARGB\_8888 [Config](http://developer.android.com/reference/android/graphics/Bitmap.Config.html) and disable dithering.
* Remove the Window [background](http://android-developers.blogspot.com/2009/03/window-backgrounds-ui-speed.html) if possible.
* Enable hardware acceleration, but beware of [unsupported operations](http://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported).

On a 2.1 device, I am able to draw at least 300 bitmaps on-screen at 50 fps.
I think you can get good performance out of a canvas.. but it takes a lot of work.. 

if you start off with a good performance graphics library, then even if you get a lot of things wrong, you probably will still end up with good performance :) lol

there is a competition running for the fastest drawing library... libgdx is currently winning...

<http://code.google.com/p/libgdx/wiki/SimpleApp#Project_Setup>