Android将多个位图图块流式传输到单个jpeg文件 [英] Android stream multiple bitmap tiles to single jpeg file

查看:79
本文介绍了Android将多个位图图块流式传输到单个jpeg文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一种图像处理应用程序,该应用程序必须能够处理大型图像,例如相机拍摄的图像,我要采取的方法是将源图像分割为多个适当大小的图块,以便这些图块可以作为位图单独加载到内存中,而不会超出可怕的VM限制,接下来对图像进行操作逐块地进行,这一切都很好,但是直到我想将这些块拼接回最终的jpeg图像.
我正在寻找可以执行以下操作的内置sdk api或免费软件解决方案:

I am developing an image manipulation application which has to be able to work on large images e.g. those taken by a camera, the approach I'm taking is to split the source image into multiple suitably sized tiles so that the tiles can be loaded individually into memory as a Bitmap without exceeding the dreaded VM limit, next image manipulation is performed on a tile by tile basis, this is all well and good but until I want to stitch these tiles back to a final jpeg image.
I'm looking for a built in sdk api or free ware solution that can perform the following:

  • 打开jpeg输出文件作为输出流
  • 将RGB像素从位图(图块1)流向jpeg输出流
  • 将RGB像素从位图(图块2)流向jpeg输出流
  • 所有瓷砖的
  • 等.
  • 关闭jpeg输出流
  • Open jpeg output file as output stream
  • Stream RGB pixels from bitmap (tile 1) to jpeg output stream
  • Stream RGB pixels from bitmap (tile 2) to jpeg output stream
  • etc.. for all tiles
  • Close jpeg output stream
  • 除了编写自己的jpeg编码器之外,还有其他想法或指针吗?

    Any ideas or pointers other than writing my own jpeg encoder?

    推荐答案

    您的拼接方法有两个主要问题,最终将失败.如果您要求系统对JPEG文件进行部分解码,则解码时间最终将接近N倍(N =部分数量).下一个问题是,当尝试保存图像时,内存将用完. JPEG图像需要一次性压缩.如果您整个未压缩的图像都无法容纳在内存中,那么您将无法使用正在使用的技术.

    Your stitching approach has two major issues and will ultimately fail. If you ask the system to decode a JPEG file in parts, the decode time will end up being close to N times longer (N = number of parts). The next problem is that when trying to save the image you will run out of memory. JPEG images need to be compressed in one shot. If your entire uncompressed image can't fit in memory, then you won't be able to use the technique you're using.

    硬道理是,对于当前设计的Android,必须使用本机代码来保留位图,才能管理大于VM内存限制的图像.并不是那么困难,但是确实需要重新设计您的应用程序.

    The hard truth is that, with Android as it is currently designed, you must use native code to hold on to the bitmap in order to manage an image larger than the VM memory limit. It's not that difficult, but it does require a re-design of your app.

    这篇关于Android将多个位图图块流式传输到单个jpeg文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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