Android的 - 动画通过绘制位图不顺畅 [英] android - animation by drawing bitmap is not smooth

查看:210
本文介绍了Android的 - 动画通过绘制位图不顺畅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果我试图通过绘制它们的表面持有者画布动画几种形状(路径)。
起初我画他们的路径和一切都很好,动作顺利。
正如我增加了对象(形状)的数量的性能下降,我做了一些
测试看看,如果不是绘制形状绘制位图的速度更快。和..绘图
位图似乎是相当快(更少的计算可能),但运动
不光滑。它看起来像位图总是从像素移动像素,而不是使用反别名,我不知道,提请各国一半像素。
该方法的签名如下所示:结果


I am trying to animate several shapes(paths) by drawing them on the surface holders canvas. At first I was drawing them as paths and everything was fine, the movement was smooth. As I increased the number of objects(shapes) the performance decreased and I made some tests to see if instead of drawing shapes drawing bitmaps is faster. And.. drawing bitmaps seems to be considerable faster (less computation maybe) BUT the movement is not smooth. It looks like the bitmaps always move from pixel to pixel instead of using anti alias to, I dont know, draw states as half pixel. The signature of the method looks like :

canvas.drawBitmap(cloudBitmap, float left, float top, Paint p);

结果
这表明,我应该能够在0.5F像素绘制位图。


which suggests that I should be able to draw a bitmap at 0.5f pixels.

任何想法,为什么?

推荐答案

我想这可能是由于没有位图过滤它光滑正在绘制。您已设置的油漆来平滑位图?如果不是,这可能是您的解决方案。

I think it might be due to the bitmap being drawn without filtering it for smoothness. Have you set the paint to smooth the bitmap? If not, that might be your solution.

Paint paint = new Paint();
paint.setFilterBitmap(true);

这篇关于Android的 - 动画通过绘制位图不顺畅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆