- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试以大约 5MP 的速度旋转使用 Android 设备的相机拍摄的图像。不幸的是它只工作一次。之后我得到一个“内存不足”的异常。即使我释放了以前使用过的图像,它看起来它的数据仍然占用内部图像堆/存储并以某种方式阻止进一步的旋转操作。是否有任何已知的解决此问题的好方法(例如,释放图像内存,旋转图像而不需要两倍的内存大小)?
最佳答案
让相机给你一个已经旋转的图像:
public void setCameraDisplayOrientation(int cameraId, android.hardware.Camera camera) {
android.hardware.Camera.CameraInfo info = new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
int rotation = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
int degrees = 0;
switch (rotation) {
case Surface.ROTATION_0:
degrees = 0;
break;
case Surface.ROTATION_90:
degrees = 90;
break;
case Surface.ROTATION_180:
degrees = 180;
break;
case Surface.ROTATION_270:
degrees = 270;
break;
}
int result;
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
result = (info.orientation + degrees) % 360;
result = (360 - result) % 360; // compensate the mirror
} else { // back-facing
result = (info.orientation - degrees + 360) % 360;
}
// set the right preview orientation
camera.setDisplayOrientation(result);
// make the camera output a rotated image
Camera.Parameters cameraParameters = camera.getParameters();
cameraParameters.setRotation(result);
camera.setParameters(cameraParameters);
}
关于安卓大图旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5372620/
我有两种尺寸的图像(垂直和水平),它们将始终具有相同的尺寸,恭敬。我正在尝试创建一个容器来容纳图像但不会将内容推到上面并保持相似的高度或宽度。我也不想显示完整尺寸的图像,所以我在考虑使用 overfl
我有一个使用该类的 LaTeX 文档 \documentclass[12pt,a4paper]{scrbook} 我更改了一些用于定位浮点数的参数: \renewcommand{\topfractio
我有一个问题想和你分享。 所以就在这里。想象一下,我有一个非常大的图像,当我打开我的页面时它需要很重的负载。如果我想要将图像剪切成许多小块并在加载图像时将它们一个接一个地合并(只是 javascrip
我正在学习 Java SE 6.0。 是否有一张大图或图表来说明 Java 6.0 的所有类以及它们之间的关系? 提前致谢。 尊敬的 stackoverflow 开发人员和程序员。 你好。非常感谢您对
我得到了一个 InflateException 并且抛出了一个 OutOfMemoryError 异常。我知道我应该能够通过减小图像的大小/分辨率,或者通过将 android:largeHeap="t
我必须引用 id 从服务器到 android 移动设备检索所有大小的图像,所以我尝试使用下面的编码并成功获得 base 64 字符串并检索等效 base64string 的图像它适用于小尺寸图像但当我
我是一名优秀的程序员,十分优秀!