照片选择器。纵向转向横向
来源:互联网 发布:汽车模拟驾驶软件 编辑:程序博客网 时间:2024/06/10 01:01
照片选择器。纵向转向横向
1. 你必须得到该图片的EXIF旋转,这样的安排youur相应
public static int getExifRotation(String imgPath) { try { ExifInterface exif = new ExifInterface(imgPath); String rotationAmount = exif.getAttribute(ExifInterface.TAG_ORIENTATION); if (!TextUtils.isEmpty(rotationAmount)) { int rotationParam = Integer.parseInt(rotationAmount); switch (rotationParam) { case ExifInterface.ORIENTATION_NORMAL: return 0; case ExifInterface.ORIENTATION_ROTATE_90: return 90; case ExifInterface.ORIENTATION_ROTATE_180: return 180; case ExifInterface.ORIENTATION_ROTATE_270: return 270; default: return 0; } } else { return 0; } } catch (Exception ex) { return 0; }}
得到的图像的路径
public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(uri, projection, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index);}
薄做一个矩阵构造矩阵
Matrix matrix = new Matrix();matrix.preRotate(90); // ormatrix.postRotate(90);
所以你的onActivityResult里面你应该有这样的
Uri selectedImageUri = data.getData(); selectedImagePath = getPath(selectedImageUri); orientation = getExifRotation(selectedImagePath); Matrix matrix = new Matrix(); matrix.postRotate(90); if(orientation == 90){ bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);}
确保你重新取样图像第一了,所以他怎么有它在他的答案,然后再做到这一点
0 0
- 照片选择器。纵向转向横向
- JQuery 横向纵向菜单
- 横向设计,纵向实施
- 横向纵向下拉框
- JQuery 横向纵向菜单
- 横向,纵向下拉菜单
- 横向纵向打印
- jq横向纵向菜单
- Oracle横向纵向汇总
- Sql 横向转纵向
- 【JQuery】纵向横向菜单
- Oracle横向纵向求和
- div纵向、横向滚动条
- ORACLE创建横向/纵向直方图
- 纵向数据变为横向数据
- JQuery实战:横向纵向菜单
- 数据库纵向记录横向显示
- 技术人员的横向纵向发展
- 【实验一】VC编程工具的灵活运用
- 读书札记-2013年12月
- usbhid类之mouse、keyboard
- DSP6000的几个简单优化技巧
- git mindmap
- 照片选择器。纵向转向横向
- 《数据结构》实验一: VC编程工具的灵活使用
- 数字信号处理的学习资源
- 汉澳sinox的先进文件系统zfs轻松击败微软ReFS和linux的btrfs
- java之多线程实例
- alibaba technology
- memcpy的实现
- iOS选择头像示例代码
- 嵌入式工程师应该知道的C语言 .