Nik*_*kki 12
要执行图像的旋转,您可以使用以下代码:
Bitmap bMap = BitmapFactory.decodeResource(getResources(),R.drawable.test);
Matrix mat = new Matrix();
mat.postRotate(90);
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,
bMap.getWidth(), bMap.getHeight(), mat, true);
BitmapDrawable bmd = new BitmapDrawable(bMapRotate);
image.setImageBitmap(bMapRotate);
image.setImageDrawable(bmd);
Run Code Online (Sandbox Code Playgroud)
对于从图库中获取的图像裁剪,请使用以下代码片段:
Intent viewMediaIntent = new Intent();
viewMediaIntent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/image/*");
viewMediaIntent.setDataAndType(Uri.fromFile(file), "image/*");
viewMediaIntent.putExtra("crop","true");
viewMediaIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivityForResult(viewMediaIntent,1);
Run Code Online (Sandbox Code Playgroud)
希望,这对你有所帮助.
| 归档时间: |
|
| 查看次数: |
24347 次 |
| 最近记录: |