【发布时间】:2014-06-06 05:54:46
【问题描述】:
我想旋转并保存我使用 Android Native Camera 拍摄的图像到 sdcard。因为原生相机默认为横向。但是我不想使用位图。有可能这样做吗?请帮忙。我是安卓开发新手。
由于我的图像旋转了 90 度,我需要在保存之前使用 位图 旋转它。 但在某些设备上 bmp 即将 null。
相机活动布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
清单文件
<activity
android:name="com.example.androiddms.CameraActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/title_activity_camera"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
Camera Activity.java
FileOutputStream fos = new FileOutputStream(pictureFile);
Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
Matrix matrix = new Matrix();
matrix.postRotate(90);
bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
bmp.compress(Bitmap.CompressFormat.JPEG, 100,fos);
【问题讨论】:
-
位图遇到什么问题?
-
位图占用大量内存。尽管存在一些技术来处理它们。但我只是想试试是否可以在不使用 Bitmaps 的情况下保存 Captured Image。
标签: android bitmap android-camera android-canvas