加载大图在Android的位图 [英] Loading big image to bitmap in android

查看:114
本文介绍了加载大图在Android的位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我使用跌破code,它运行正常加载从SD卡的图像,

Hi i am using below code to load images from sdcard, it is running correctly,

Bitmap picture=BitmapFactory.decodeFile("/sdcard...");

Bitmap picture= BitmapFactory.decodeByteArray(byte[]..);  

字节[] 数组包含的FileInputStream 通过使用SD卡读取字节,并且不为空。两个以上codeS的正常工作。的问题是,它们不工作为更大,例如图像我有1.8 MB大小的图像。而图像解码我的应用程序崩溃。任何用于拉尔图像的方法失败。 任何解决方案PLZ thakns。

The byte[] array contains bytes read from sdcard by using FileInputstream and is not null. Both of above codes work fine. The problem is that they dont work for images that are larger e.g. i have an image of 1.8 mb in size. My app crashes while decoding the image. Any method used for larges image fails. Any solution plz thakns.

推荐答案

尝试创建吹出的位图。

   byte[] data = ...(read byte array from file)
   BitmapFactory.Options opt = new BitmapFactory.Options();
   opt.inPurgeable = true;
   Bitmap picture = BitmapFactory.decodeByteArray(data, 0, data.length, opt); 

这篇关于加载大图在Android的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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