小编vfr*_*chi的帖子

在一次使用多个YuvImage时使用compresstojpeg时内存不足

我正在构建一个缓冲N个相机帧的应用程序,当用户点击一个按钮时,它会使用应用效果的所有已保存帧保存照片.

我正在保存照片并在AsyncTask上处理帧.当我执行它时,我从屏幕上删除所有内容,只留下一个TextView来显示保存照片的进度.

目前AsyncTask doInBackground看起来像这样:

protected Void doInBackground(Integer... params) 
{
    int w = mBuffer.get(0).getWidth();
    int h = mBuffer.get(0).getHeight();
    int lineHeight = h / mBuffer.size();
    int currentHeight = 0;

    Log.d("output", "saving photo "+w+", "+h);

    for (int i = 0; i < mBuffer.size(); i++)
    {
        YuvImage image = mBuffer.get(i);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        if (!image.compressToJpeg(new Rect(0, currentHeight, w, lineHeight), 50, out))
        {
            Log.d("output", "problem converting yuv to jpg");
            break;
        }

        currentHeight += lineHeight;

        Log.d("output", …
Run Code Online (Sandbox Code Playgroud)

android image-processing yuv out-of-memory

5
推荐指数
1
解决办法
3628
查看次数

标签 统计

android ×1

image-processing ×1

out-of-memory ×1

yuv ×1