Android的处理内存溢出异常图像处理 [英] Android handling out of memory exception on image processing

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

问题描述

这是这个问题的序列部分:<一href="http://stackoverflow.com/questions/3674441/combining-2-images-overlayed">http://stackoverflow.com/questions/3674441/combining-2-images-overlayed

This is the sequence part of this question: http://stackoverflow.com/questions/3674441/combining-2-images-overlayed

所以这个问题是:如果图像尺寸过大 - 它会得到一个异常(内存溢出异常) 我要的是,处理即使手机拿到了低规格硬件,它不会去那个异常(但它会需要更长的时间来处理图像)

so the problem is: if the image size is too big - it'll got an exception (out of memory exception) what i want is, to handle even if the handset got the lower spec hardware, it doesn't go to that exception (but it'll take a longer time to process the image)

是有可能做到这一点?

在code段是这样的:

the code snippet is like this:

public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
    Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
    Canvas canvas = new Canvas(bmOverlay);
    canvas.drawBitmap(bmp1, new Matrix(), null);
    canvas.drawBitmap(bmp2, 0, 0, null);
    return bmOverlay;
}

和code表示块是异步任务里。

and that block of code is inside the async task.

我真的AP preciate如果有人能帮助我在这个问题上。

I really appreciate if someone can help me on this matter.

感谢您和问候, 和

推荐答案

我觉得你没有选择,而是要重新调整位图在一个较低的尺寸......

I think you have no choice, but to rescale the bitmaps in a lower size...

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

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