问题描述
我只是想从我的应用程序打开机摄像头应用程序来拍摄照片并将其设置为我的屏幕的背景图像,然后将其旋转的onclick按钮。照片旋转n次如果采取300万像素摄像头。如果我的相机分辨率设置为500万像素以上,应用程序是强制关闭的按钮第5次点击(图片旋转4次)。
I just want to open native camera app from my app to capture a photo and set it as a background image of my screen then rotate it onclick of button. Photo is rotating n number of times if it is taken with 3MP camera. If i set camera resolution to 5MP or more, app is force closing on click of button 5th time (photo is rotating 4 times) .
Bitmap rotatedBitmap = null;
int curAngle = 0;
private Bitmap rotateImageBitmap(Bitmap capturedPhotoBitmap) {
if(rotatedBitmap != null )
{
rotatedBitmap = null;
}
Matrix matrix = new Matrix();
curAngle = (curAngle + 90) % 360;
matrix.postRotate(curAngle);
rotatedBitmap = Bitmap.createBitmap(capturedPhotoBitmap, 0, 0, capturedPhotoBitmap.getWidth(), capturedPhotoBitmap.getHeight(), matrix, true);
return rotatedBitmap;
}
这是从开发人员指南....
1。
移动设备通常具有有限的系统资源。 Android设备可以有16MB的内存可供一个单一的应用程序少。
This is from Developer Guide ....
1.Mobile devices typically have constrained system resources. Android devices can have as little as 16MB of memory available to a single application.
2。
位图占用了大量的内存,特别是对丰富的图像,例如照片。例如,在Galaxy Nexus的摄像头所拍摄照片达2592x1936像素(5百万像素)。如果使用的位图配置ARGB_8888(从Android 2.3以后默认),那么这个图像加载到内存大约需要的内存(2592 * 1936 * 4字节)19MB,马上耗尽在某些设备上的每个应用程序的限制。
2.Bitmaps take up a lot of memory, especially for rich images like photographs. For example, the camera on the Galaxy Nexus takes photos up to 2592x1936 pixels (5 megapixels). If the bitmap configuration used is ARGB_8888 (the default from the Android 2.3 onward) then loading this image into memory takes about 19MB of memory (2592*1936*4 bytes), immediately exhausting the per-app limit on some devices.
大多数手机都时下800万像素摄像头或更高。这样的照片会很大。
如何旋转我的照片N的次数没有摄像头分辨率的困扰。我是否需要COM preSS呢?什么是最好的办法吗?请帮帮我。
Most phones nowadays have cameras 8mp or higher. so pictures will be large.How can i rotate my photo 'n' number of times without bothering of camera resolution. Do i need to compress it ? What is the best way? Please help me.
推荐答案
还有就是Android开发者网站上整个教程关于阅读和显示大的位图:
there is a whole tutorial on the android developers website about reading and displaying large bitmaps:
这篇关于在处理大量的Android位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!