调用canvas.drawBitmap时系统会发生什么?

发布于 2024-09-14 09:39:44 字数 430 浏览 5 评论 0原文

我有一个可滚动和可缩放的地图,它具有地图的低分辨率副本,该副本在缩放比例较小时绘制,并且在用户放大超过某个点时绘制平铺系统。我遇到的问题是,第一次绘制图块时会出现短暂但明显的滞后。在最初的滞后之后,一切都很顺利。 GC 未运行,所有位图均在启动时加载。知道到底发生了什么以便我可以解决延迟问题吗?或者有什么办法可以解决吗?谢谢。下面是代码:

            canvas.drawBitmap(map, null, bgRect,paint);

            if(matrix[0]>.9){
                 mapPicture = makeMyMap(xScale,yScale); //make/update our map.
                 mapPicture.draw(canvas);  
            }

I have a scrollable and zoomable map which has a low res copy of the map which is drawn when the zoom scale is small and a tile system when the user zooms in past a certain point. The problem im having is that the very first time the tiles are drawn there is a short, but noticable lag. After that initial lag everything is smooth. The GC isnt running, and all the bitmaps are loaded at launch time. Any idea what exactly is going on so i can take care of the lag? Or any way for a work around? Thanks. Heres the code below:

            canvas.drawBitmap(map, null, bgRect,paint);

            if(matrix[0]>.9){
                 mapPicture = makeMyMap(xScale,yScale); //make/update our map.
                 mapPicture.draw(canvas);  
            }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖粟与秋泊 2024-09-21 09:39:44

尝试使用 DDMS 打开跟踪,以确定哪些方法在第一次绘制时需要很长时间,并查看它们与后续绘制的比较情况。

drawBitmap 有可能在第一次绘制而不是加载时触发平台级别的图像放大/缩小 - 但这是我的猜测。

Try switching on tracing with DDMS to establish which methods take a long time on the first draw and see how they compare with the subsequent draws.

It's possible that drawBitmap is triggering the platform level up-scale / down-scale of the images on first draw rather than load - but that's speculation on my part.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文