简体   繁体   English

如何在Android中创建大型位图?

[英]How might one create a large Bitmap in Android?

I am trying to build an Android application which can take several photos taken by the camera, and merge them into one giant image. 我正在尝试构建一个Android应用程序,该应用程序可以拍摄相机拍摄的几张照片,然后将它们合并为一张大图像。 For example, I might take three photos and arrange them in a vertical stack for output as a single image. 例如,我可能拍摄了三张照片,并将它们排列在垂直堆栈中,以作为单个图像输出。 Ideally, I'd like to be able to keep the images at the original size. 理想情况下,我希望能够将图像保持原始尺寸。 Unfortunately, using Bitmap.createBitmap() causes an OutOfMemoryException before even approaching the size of one photo of camera dimensions. 不幸的是,使用Bitmap.createBitmap()会导致OutOfMemoryException,甚至无法达到相机尺寸的一张照片的大小。 Is this possible? 这可能吗? Or do I just need to resort to scaling the photos before trying to merge them into a single Bitmap? 还是我只需要在尝试将照片合并为单个位图之前缩放它们?

What is your goal? 你的目标是什么?

If your goal is to upload the combined image, have the server combine them, since it has a wee bit more CPU and RAM than do most Android devices. 如果您的目标是上传组合的图像,请让服务器对其进行组合,因为它比大多数Android设备具有更多的CPU和RAM。

If your goal is to display the combined image, since each piece of the combined image is going to be bigger than the screen size, treat the image pieces as tiles -- don't combine them, but draw them as needed as the user scrolls around the virtual combined image space. 如果您的目标是显示合成的图像,由于合成的图像的每个部分都将大于屏幕尺寸,请将这些图像块视为图块-不要合并,而是在用户滚动时根据需要绘制它们在虚拟组合图像空间周围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM