简体   繁体   中英

PNG compression for live wallpapers in Android

I'm trying to create a live wallpaper in Android but am having trouble with the PNG that I use for the background. When I slide home screens the transition is very laggy. My background PNG is 1024x576px 96dpi 1.01MB photo. It also has a transparent region.

c.drawBitmap(BitmapFactory.decodeResource(getResources(),
                R.drawable.foreground),mX,mY,null);


c.translate(mX, 0f);

I use this code for loading and translating the PNG.

What's the best to compress this PNG, or do I need to code it differently?

I've found the problem. I was loading my PNG each time my wallpaper went into an animation loop, instead of loading it once when the surface is created.

fG =BitmapFactory.decodeResource(getResources(),
                R.drawable.foreground);

This code should be in the onCreate() method. Stupid me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM