Android上的低成本位图旋转

时间:2012-07-03 09:50:03

标签: android bitmap live-wallpaper

我正在为自己的动态壁纸编写代码。 壁纸(以及其他内容)具有连续旋转的背景位图。位图很大(768x768px)。我做的每个屏幕刷新:

canvas.drawColor(Color.WHITE);
Matrix matrix = new Matrix();
matrix.setRotate(degrees, background.getWidth() / 2, background.getHeight() / 2);
canvas.drawBitmap(background, matrix, paint);

壁纸将以12-18 FPS运行。 这太重了吗?有没有更好的方法来做到这一点?提前谢谢。

1 个答案:

答案 0 :(得分:1)

您可以尝试使用Animation

对于示例示例,

RotateAnimation animationRotator = new RotateAnimation(0f, 360f, 10f, 10f);
animationRotator.setInterpolator(new LinearInterpolator());
animationRotator.setRepeatCount(Animation.INFINITE); // For Infinite Rotation
animationRotator.setDuration(1000); // Duration in which one rotation should get over

yourView.startAnimation(animationRotator);
相关问题