任何尺寸的Andr​​oid显示位图 [英] Display bitmap of any size in Android

查看:92
本文介绍了任何尺寸的Andr​​oid显示位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示从SD卡中的Andr​​oid读实际像素大小的位图。

I want to display a bitmap read from the SD card at actual pixel size in Android.

我不能假设对位图什么,比Android等支持的图像格式。位图可能是巨大的。

I can't assume anything about the bitmap, other than Android supports its image format. The bitmap might be huge.

看起来很简单,但是当你的Andr​​oid因素内存的限制,它变得更加复杂。

Seems simple enough, but when you factor Android memory limitations it gets much more complicated.

任何想法?

修改:试图加载一个大的位图给出了内存不足的错误,因为Android是无法分配足够的内存来解code吧。可以加载位图的缩小版本,但是这是没有用的,以显示该位图在实际像素大小。现在的问题是如何显示在Android上一个大的位图,而应用程序的内存限制范围内保持(最有可能通过加载它的块)。

Edit: Attempting to load a large bitmap gives an out of memory error because Android is not able to allocate enough memory to decode it. You can load a scaled down version of the bitmap, but this is not useful to show the bitmap at actual pixel size. The question is about how to show a large bitmap on Android while staying within the app's memory constraints (most likely by loading it in chunks).

编辑2 :位图可能是巨大的,但合理的范畴之内。我说的是用户的图像,而不是HD美国宇航局的图片。

Edit 2: The bitmap might be huge, but within the realm of reasonable. I'm talking about user images, not HD Nasa pictures.

推荐答案

由于Android 2.3(姜饼,API等级10),你可以使用的 Bitma pregionDe codeR 。我不知道对老年人的Andr​​oid版本的任何解决方案。 (我一直在寻找它为我EmailAlbum应用程序)

Since android 2.3 (Gingerbread, API Level 10), you can use the BitmapRegionDecoder. I don't know any solution for older android versions. (and I've been looking for it for my EmailAlbum app)

这篇关于任何尺寸的Andr​​oid显示位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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