大佬教程收集整理的这篇文章主要介绍了使用ARGB_8888时,Android DrawBitMap非常慢,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
创建空白位图
Rectangle = Bitmap.createBitmap(320,480,Bitmap.Config.ARGB_8888); Circle = Bitmap.createBitmap(70,70,Bitmap.Config.ARGB_8888); Leaf1 = Bitmap.createBitmap(20,30,Bitmap.Config.ARGB_8888);
在适当的BitMap上绘制形状
Canvas c = new Canvas(RectanglE); Paint p = new Paint(); p.setAntiAlias(true); p.setColor(0xff6e8b3E); c.drawRect(0,320,p); Canvas c = new Canvas(CirclE); Paint p = new Paint(); CirclePath = new Path(); p.setAntiAlias(true); p.setColor(0xffcd661d); System.out.println("x = "+x+" y = "+y); CirclePath.addCircle(50,50,10,Path.Direction.CW); c.drawPath(CirclePath,p); Canvas c = new Canvas(Leaf1); Paint paint = new Paint(); Path path = new Path(); paint.setAntiAlias(true); path.moveTo((float)184.37,(float)219.15); path.cubicTo((float)188.32,(float)219.15,(float)192.88,(float)220.44,(float)195.62,(float)223.54); path.cubicTo((float)197.84,(float)226.05,(float)203.2,(float)229.84,(float)198.18,(float)245.98);
在OnDraw中绘制BitMap
canvas.drawBitmap(Rectangle,p); canvas.translate(x,y); // For animation effect canvas.drawBitmap(Circle,p); canvas.drawBitmap(Leaf1,p);
现在,当我记录这三个drawBitMap的时间时,我发现它需要大约50ms
代码中是否存在重大错误.将Bitmap.Config更改为RGB_565会将时间缩短到8毫秒左右,但背景不可见,我在路径周围有一个黑框
您可以尝试切换到OpenGL ES或尽可能少透明地设计内容,这样您就可以尽可能频繁地使用RGB_565.
@H_450_19@ @H_450_19@以上是大佬教程为你收集整理的使用ARGB_8888时,Android DrawBitMap非常慢全部内容,希望文章能够帮你解决使用ARGB_8888时,Android DrawBitMap非常慢所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。