Question

When rendering my live wallpaper I have some banding gradient artifacts. This article perfectly explains the reason behind this: to eliminate most of them and improve efficiency I can draw 32 bit bitmaps on top of 32 bit bitmaps :)

So I asked myself a question: how to do this for live wallpaper? And din't find an answer :) In live wallpapers we have a surface created for us by android framework. And it happens so that it is a RGB_565 surface, because:

// code inside my WallpaperService.Engine subclass
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height)
{
   Log.d("test", "format is: "+format); // => prints 4, which is PixelFormat.RGB_565
}

And it seems there's no way I can ask Android framework to change this to be ARGB_8888. Or is there?

P.S. Of course I know I can do other stuff described in the above article like applying dithering etc, so please do not bother pointing me this. I'd like to find an answer exactly to the question I asked :)

Was it helpful?

Solution

Set the PixelFormat inside onCreate()

holder.setFormat(PixelFormat.RGBA_8888);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top