Android 旋转从uri获取的图像
我有一个imageviewer应用程序组件,它正在从uri接收图像。我如何旋转它?矩阵似乎不起作用。这是我的密码 公共类ImageViewer扩展活动{Android 旋转从uri获取的图像,android,matrix,Android,Matrix,我有一个imageviewer应用程序组件,它正在从uri接收图像。我如何旋转它?矩阵似乎不起作用。这是我的密码 公共类ImageViewer扩展活动{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceStatey); setContentView(R.layout.image_view_layout); Uri uri = getIntent(
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceStatey);
setContentView(R.layout.image_view_layout);
Uri uri = getIntent() != null ? getIntent().getData() : null;
ImageView img = (ImageView) findViewById(R.id.imageView);
img.setImageURI(uri);
Matrix matrix=new Matrix();
matrix.postRotate(90);
img.setImageMatrix(matrix);
一些android旋转代码。将您的URI提供给解码器
Bitmap lbit =
BitmapFactory.decodeStream(
getContentResolver().openInputStream(_uri),null,options);
Log.i(TAG, "Rotating... " + rotation);
lbit = lbit.copy(Bitmap.Config.ARGB_8888, true);
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
lbit = Bitmap.createBitmap(lbit, 0, 0, lbit.getWidth(),
lbit.getHeight(), matrix, true);
检查下面的链接,示例正在加载位图,但我正在从Uri获取图像。您可以使用Uri检索位图对象,然后应用旋转!好的,非常感谢