在Android手机上显示巨大的平铺图像
我有一个非常大的图像(地图)需要显示。我已经有了“平铺”格式的图像 - 256x256 块。 我还获得了几个“缩放”级别的图块。
目前的问题是显示最深的缩放级别,其中您实际上会有很多图块。 例如,中等大小的地图将包含 4 行和 26 列的深度图块。
我尝试使用二维滚动视图和其中的图像视图来解决这个问题 - 每个图块 1 个。 问题是它会崩溃。当我尝试显示 4 行 20 列时,它没有崩溃,显然这是内存问题。
所以这里的问题是——考虑到手机内存有限,如何显示所有这些。 我确实知道应该有一种方法可以为看不见的图像释放内存,并且只显示当前位于滚动视图可见区域的图像,但我不知道该怎么做。
很高兴听到任何线索,或者也许有其他方法来解决这些问题。
谢谢。
I have a very large image (a map) that I need to display. I already have the image in "tiled" format - 256x256 pieces.
Also I got tiles for several "zoom" levels.
At the moment the issue is to display the deepest zoom level, where you'd have really a lot of tiles.
For example, a medium sized map will contain 4 rows and 26 columns of tiles for deep level.
I tried approaching the problem using a 2 dimensional scroll view and image views inside it - 1 per tile.
The problems is that it crashes. When I try displaying 4 rows and 20 columns it doesn't crash, obviously it's a memory issue.
So the question here - how to display all that, taking into account limited phone RAM.
I do understand there should be a way to dealocate memory for images that are out of sight, and only display those which are currently in visible area of the scroll view, but I don't know how to do that.
Would be happy to hear any clues or maybe there's alternative approach to these things.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你最好使用网格视图而不是滚动视图数组(但我不确定它是否同时支持侧面/上下滚动。
然后在你的适配器中,重写 getView 方法在那里你可以控制图像的回收。
我正在做的项目也有图像和 RAM 的问题,我基本上做的是这样的:
我尝试用 800x400x32 位的图像做上面的事情,但仍然没有运行。但如果我删除 System.gc(),它会立即崩溃。
I think you might better use the grid view instead of arrays of scroll view (but I am not sure if it support side/updown scroll at the same time.
And then in your adapter, override the
getView
method. There you can control the recycling of your images.The project I am doing also have issues with image and RAM, what I am basically doing is like:
I tried doing the above stuff like 50fps with the image is like 800x400x32bit and still not running into out of memory issue. But if I take away the System.gc(), it crash immediately.