Android的PNG图像大内存 [英] Android png images big in memory

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

问题描述

我在android的,有一个imageflipper的应用程序。问题是,经过约8个图像加载到内存中,我得到一个内存不足的错误。

I have an application in android that has an imageflipper. Problem is, after about 8 images loaded to memory, I get an out of memory error.

嗯,我试着做动态的图像加载,因此,如果用户翻转2图像,我会加载未来2至存储和删除2首当其冲。那种它的工作原理,但它是丑陋的,我有麻烦,当用户翻转图像回(imageflipper.show previous()),我真的不能转移所有图像,并把新的图像开始。

Well, I tried to do dynamic image loading, so that if the user flips 2 images, I'll load next 2 to memory and delete 2 first ones. It kind of works, but it is ugly and I have trouble when user flips images back(imageflipper.showprevious()), I can't really shift all images and place new images to the beginning.

我的问题是:
有没有更好的办法做这样的东西?调整图像大小并没有真正的帮助。

My question is:
Is there a better way to do this kind of stuff? Resizing images didn't really help.

推荐答案

使用的 BitmapFactory.Options

BitmapFactory.Options opts = new BitmapFactory.Options();
opt.inSampleSize = 2;
//this will decrease bitmap size,
// but also affect quality of the image, 
//so just play with this value to spot the good one;
Bitmap b = BitmapFactory.decodeFile(fileName, opts);

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

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