由于本人英文能力实在有限,不足之初敬请谅解

本博客只要没有注明“转”,那么均为原创,转贴请注明本博客链接链接

Displaying Bitmaps Efficiently

高效显示Bitmap

Learn how to use common techniques to process and load Bitmap objects in a way that keeps your user interface (UI) components responsive and avoids exceeding your application memory limit.

If you're not careful, bitmaps can quickly consume your available memory budget leading to an application crash due to the dreaded exception:

java.lang.OutofMemoryError: bitmap size exceeds VM budget.

学习如何使用常规技术来处理和加载Bitmap对象,在一定程度上可以保持你的UI组件响应性以及避免超过应用内存限制。

如果你不小心,bitmap能很快消费光你的可用内存,由于下面可怕的异常导致应用崩溃

java.lang.OutofMemoryError: bitmap size exceeds VM budget.

There are a number of reasons why loading bitmaps in your Android application is tricky:

一些原因是为什么在你的android应用里加载bitmap是需要技巧的:

Mobile devices typically have constrained system resources.

Android devices can have as little as 16MB of memory available to a single application.

The Android Compatibility Definition Document (CDD), Section 3.7. Virtual Machine Compatibility gives the required minimum application memory for various screen sizes and densities.

Applications should be optimized to perform under this minimum memory limit.

However, keep in mind many devices are configured with higher limits.

移动设备往往资源系统有限

android设备对一个应用来说至少有16MB的可用内存。

Android Compatibility Definition Document (CDD),章节3.7,Virtual Machine Compatibility

应用在这种最小内存限制下,应该最优化的被执行

然而,有很多设备配置了更高的限制

Bitmaps take up a lot of memory, especially for rich images like photographs.

For example, the camera on the Galaxy Nexus takes photos up to 2592x1936 pixels (5 megapixels).

If the bitmap configuration used is ARGB_8888 (the default from the Android 2.3 onward) then loading this image into memory takes about 19MB of memory (2592*1936*4 bytes), immediately exhausting the per-app limit on some devices.

Bitmap占用大量内存,尤其是像照片一类色彩丰富的图片

例如:Galaxy Nexus上面的相机拍出的照片需要2592x1936像素(5 megapixels).

如果bitmap使用ARGB_8888做配置(android2.3之前的默认配置),那么加载这张图片到内存中大概需要19MB(2592*1936*4 bytes),在一些设备上,马上就耗尽了单个app限制

Android app UI’s frequently require several bitmaps to be loaded at once.

Components such as ListView, GridView and ViewPager commonly include multiple bitmaps on-screen at once with many more potentially off-screen ready to show at the flick of a finger.

android应用UI频繁的需要一次同时加载多张图片

像ListView,ridView 和 ViewPager这样的组件,通常一次同时含有多张图片在屏幕上,还有很多在屏幕外准备当手指滑动时显示的图片

(下面提到了5篇文章已经翻译完,链接直接链到我翻译后的文章)

Lessons

Loading Large Bitmaps Efficiently

This lesson walks you through decoding large bitmaps without exceeding the per application memory limit.

这节教你如何不超出单个应用内存限制解码大图片

Processing Bitmaps Off the UI Thread

Bitmap processing (resizing, downloading from a remote source, etc.) should never take place on the main UI thread.

This lesson walks you through processing bitmaps in a background thread using AsyncTask and explains how to handle concurrency issues.

bitmap处理(缩放、从远程下载等)绝不应该在主线程中发生

这一节教你使用AsyncTask如何在后台线程处理bitmap,并且解释如何处理并发问题

Caching Bitmaps

This lesson walks you through using a memory and disk bitmap cache to improve the responsiveness and fluidity of your UI when loading multiple bitmaps.

这一节教你当加载多bitmap时,使用内存bitmap缓存和磁盘bitmap缓存来改进你你的UI响应性和流畅度

Managing Bitmap Memory

This lesson explains how to manage bitmap memory to maximize your app's performance.

这一节解释如何管理bitmap内存来最大化你应用的性能

Displaying Bitmaps in Your UI

This lesson brings everything together, showing you how to load multiple bitmaps into components like ViewPager and GridView using a background thread and bitmap cache.

这节把所有事情放到一起,展示如何使用后台线程和bitmap缓存加载多图片到ViewPager 和 GridView组件中

原文地址如下,英文水平实在有限,希望拍砖同时能给予指正。

http://developer.android.com/training/displaying-bitmaps/index.html

转贴请保留以下链接

本人blog地址

http://su1216.iteye.com/

http://blog.csdn.net/su1216/

android 高效显示Bitmap - 开发文档翻译的更多相关文章

  1. android 在你的UI中显示Bitmap - 开发文档翻译

    由于本人英文能力实在有限,不足之初敬请谅解 本博客只要没有注明“转”,那么均为原创,转贴请注明本博客链接链接 Displaying Bitmaps in Your UI 在你的UI中显示Bitmap ...

  2. android 缓存Bitmap - 开发文档翻译

    由于本人英文能力实在有限,不足之初敬请谅解 本博客只要没有注明“转”,那么均为原创,转贴请注明本博客链接链接 Loading a single bitmap into your user interf ...

  3. android 在UI线程之外处理Bitmap - 开发文档翻译

    由于本人英文能力实在有限,不足之初敬请谅解 本博客只要没有注明“转”,那么均为原创,转贴请注明本博客链接链接 Processing Bitmaps Off the UI Thread 在UI线程之外处 ...

  4. android <application> 开发文档翻译

    由于本人英文能力实在有限,不足之初敬请谅解 本博客仅仅要没有注明"转",那么均为原创.转贴请注明本博客链接链接 <application>语法:    <appl ...

  5. Android bitmap高效显示和优化

    第一部分:Bitmap高效显示 应用场景:有时候我们想在界面上显示一个网络图片或者显示一张本地的图片,但是图片本身是很大的有几兆,但是显示的位置很小或者说我们可以用更小的图片来满足这样的需求,如果把整 ...

  6. android 管理Bitmap内存 - 开发文档翻译

    由于本人英文能力实在有限,不足之初敬请谅解 本博客只要没有注明“转”,那么均为原创,转贴请注明本博客链接链接   Managing Bitmap Memory 管理Bitmap内存 In additi ...

  7. Android 框架修炼-自己开发高效异步图片加载框架

    一.概述 目前为止,第三方的图片加载框架挺多的,比如UIL , Volley Imageloader等等.但是最好能知道实现原理,所以下面就来看看设计并开发一个加载网络.本地的图片框架. 总所周知,图 ...

  8. Android开发文档翻译之-Services

    Service是一种能长期在后台运行同一时候不须要与用户进行交互的应用组件.其它组件能够开启service,开启后service能够自行运行及时用户已经切换到其它的应用.此外,组件能够与service ...

  9. Android高效异步图片加载框架

    概述 Android高效异步图片加载框架:一个高效的异步加载显示的图片加载框架,同时具备图片压缩,缓存机制等特性. 详细 代码下载:http://www.demodashi.com/demo/1214 ...

随机推荐

  1. python命令行解析工具argparse模块【1】

    argpaser是python中很好用的一个命令行解析模块,使用它我们可以很方便的创建用户友好型命令行程序.而且argparse会自动生成帮助信息和错误信息. 一.示例 例如下面的例子,从命令行中获取 ...

  2. NOI 能量采集

    /** 大意: 求解 在[1,n] x, [1,m] y,之间有多少个gcd(x,y) = d d = min(n,m) 思路: 对于任意一个d 在[1,n] x, [1,m] y, gcd(x,y) ...

  3. Linux学习:find、chmod、ps命令

    下面介绍下linux下find.chmod.ps这三个常见命令的使用. 这每个命令都有很多可选的参数,不同参数体现的功能不一样.我们这里不一一介绍各种参数的含义,只介绍最常见的使用场景. 一.find ...

  4. cocos2d-x游戏开发系列教程-超级玛丽08-消息机制

    在超级玛丽游戏里,地图类CMGameMap负责所有的程序逻辑,它包含了背景地图,包含了游戏元素精灵,当游戏中的精灵之间发生碰撞时,比如马里奥撞上砖头这种事情发生时,马里奥对象本身不知道怎么处理这个逻辑 ...

  5. 关于sql 中 group by 和 having

    今天看到园里一篇文章(http://www.cnblogs.com/sheldon-lou/p/4881230.html)中面试中有关sql 查询方面的问题, 想想自己从上大学就学习数据库,到后来自己 ...

  6. java学习之tcp与udp的实现

    package com.gh.socket; import java.io.BufferedReader; import java.io.IOException; import java.io.Inp ...

  7. 聊聊高并发(二十五)解析java.util.concurrent各个组件(七) 理解Semaphore

    前几篇分析了一下AQS的原理和实现.这篇拿Semaphore信号量做样例看看AQS实际是怎样使用的. Semaphore表示了一种能够同一时候有多个线程进入临界区的同步器,它维护了一个状态表示可用的票 ...

  8. 程序中使用事务来管理sql语句的执行,执行失败时,可以达到回滚的要求。

    1.设置使用事务的SQL执行语句 /// <summary> /// 使用有事务的SQL语句 /// </summary> /// <param name="s ...

  9. ViewPager+View实现Tab

    注:源码来自慕课网. 使用ViewPager+View实现Tab底部导航: 主要思想:顶部top.xml,中间ViewPager,底部线性布局Tab导航. top.xml具体实现: <?xml ...

  10. java.lang.NoClassDefFoundError: org.ksoap2.transport.HttpTransportSE异常处理

    原因就是没有打包进去  因为引用进去 编译时没出出现问题 解决如下