android 相机,图片处理
来源:互联网 发布:js关闭手机输入法 编辑:程序博客网 时间:2024/04/29 23:33
调用系统相机:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);File dir = new File(dirPath);image_name = System.currentTimeMillis() + ".png";if (!dir.exists()) {boolean iscreat = dir.mkdirs();// 创建照片的存储目录MyLog.e(TAG, "" + iscreat);}intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(new File(dir, image_name)));startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE);
拍照返回:
@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {super.onActivityResult(requestCode, resultCode, data);MyLog.v(TAG, "resultCode=" + resultCode);if (resultCode == Activity.RESULT_OK) {if (data != null) {MyLog.v(TAG, "item_id:" + data.getIntExtra("item_id", -1));}if (requestCode == REQUEST_CODE_TAKE_PICTURE) {// 拍照返回}}}
图片处理:拍照后的图片有的手机是选择90度的而且图片比较大容易造成内存溢出
public static Bitmap getSmallImage(String pathName, Context context) {MyLog.v(TAG, "getImage");BitmapFactory.Options options = new BitmapFactory.Options();options.inTempStorage = new byte[1024 * 16];//设置图片大小16Koptions.inJustDecodeBounds = true;// 获取这个图片的宽和高Bitmap bitmap = BitmapFactory.decodeFile(pathName, options); // 此时返回bm为空int maxH = SharePreferenceMng.getInstance(context).getScreenWidth() / 4;// 计算缩放比int be = (int) (options.outHeight / (float) maxH);int ys = options.outHeight % maxH;// 求余数float fe = ys / (float) maxH;if (fe >= 0.5)be = be + 1;if (be <= 0)be = 1;options.inSampleSize = be;// 重新读入图片,注意这次要把options.inJustDecodeBounds 设为 falseoptions.inJustDecodeBounds = false;bitmap = BitmapFactory.decodeFile(pathName, options);ExifInterface exifInterface;try {exifInterface = new ExifInterface(pathName);int tag = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1);if (tag == ExifInterface.ORIENTATION_ROTATE_90) {// 如果是旋转地图片则先旋转,有的相机默认旋转90度Matrix matrix = new Matrix();matrix.reset();matrix.setRotate(90);bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),bitmap.getHeight(), matrix, true);}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}return bitmap;}
0 0
- android 相机,图片处理
- Android调用相机程序和图片处理程序获得原图并且进行图片处理
- Android调用相机程序和图片处理程序获得原图并且进行图片处理
- android 调用相机 显示图片
- Android 自定义相机保存图片
- android判断相机图片朝向
- Android 自定义相机保存图片
- Android相机、相册获取图片
- android 调用相机获取图片
- Android调用相机拿到图片
- iOS软件开发获取相机图片处理
- 相机照相以及处理图片的压缩
- 处理系统相机、相册图片工具类
- Android 代码片段---从相册或相机获取图片保存并处理
- Android开发基础 调用相机 系统相册(并对图片进行压缩处理)
- android开发中调用系统的相机和图库及图片的后期处理
- Android:处理调用系统相机照片被压缩问题,图片内容看不清的问题
- Android调用系统相机、自定义相机、处理大图片
- 深度学习(Deep Learning)概述
- 王力宏闪婚携老婆李李靓蕾现身个唱【组图】 粉丝祝福盼早造人
- 如何彻底关闭Win8应用
- windows消息处理过程
- 8天学习MongoDB——第七天 运维技术
- android 相机,图片处理
- java.lang.NoClassDefFoundError: org/springframework/ui/velocity/VelocityEngi
- Win7系统操作注意事项
- 【mongoDB】监控工具之mongostat
- 企业J2EE应用实践-房产交易管理
- ibatis打印sql日志的方法,在log4j.xml中加入如下配置即可
- 纯javascript实现图片上传前预览,判断图片大小
- Jsp破解图片防盗链
- alsa分析:alsa的那些配置文件1