我有,我想表现出从URI的图片在手机Android的矩阵postRotation不起作用
我想根据它拍摄于方位转动我的图片的位图图像视图 - 但它不起作用,总是以相同的方向显示图片。
这是我的ImageView:
<!-- picture imageView -->
<ImageView
android:id="@+id/fragment_new_picture_imageview_picture"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/app_name"
android:scaleType="fitXY" />
这是我的矩阵功能:
/**
* Get the new picture {@link Bitmap} according to picture's right orientation
* @return the picture's {@link Bitmap}
*/
public Bitmap getPictureBitmap()
{
//if there is a saved instance - return it
if (pictureBitmap != null)
return pictureBitmap;
//decode bitmap
Bitmap bitmap = BitmapFactory.decodeFile(path);
//rotate bitmap
Matrix matrix = new Matrix();
matrix.postRotate(orientation);
//create new rotated bitmap
bitmap = Bitmap.createBitmap(bitmap, 0, 0,bitmap.getWidth(), bitmap.getHeight(), matrix, true);
return bitmap;
}
这是我的活动是如何在清单中提到:
<activity
android:name="com.coapps.pico.background.BackgroundActivity"
android:screenOrientation="portrait"
android:theme="@style/MainActivityTheme" >
</activity>
方向是利用查询到Media.EXTERNAL_CONTENT_URI和获取Media_ORIENTATION领域给予
在哪里以及如何设置'orientation'?调用'postRotate()'时它有什么价值? – Simon
只为你使用scaleType =“矩阵”ImageView – pskink
我从systen Image表中获取它。这和路径是从表...但问题是,无论我设置为方向它不会改变 –