android 剪切图片
来源:互联网 发布:外贸搜索客户软件 编辑:程序博客网 时间:2024/04/29 15:31
一、调用系统的剪切功能:
事件执行:
@Overridepublic void onClick(View v) {if(null == mUri)return;Intent intent = new Intent();intent.setAction("com.android.camera.action.CROP");intent.setDataAndType(mUri, "image/*");// mUri是已经选择的图片Uriintent.putExtra("crop", "true");intent.putExtra("aspectX", 1);// 裁剪框比例intent.putExtra("aspectY", 1);intent.putExtra("outputX", 150);// 输出图片大小intent.putExtra("outputY", 150);intent.putExtra("return-data", true);MainActivity.this.startActivityForResult(intent, 200);}});
效果图:
二、在onActivityResult中接受剪切数据:
protected void onActivityResult(int requestCode, int resultCode, Intent data) ....
}else if(200 == requestCode){if(resultCode == RESULT_OK){// 拿到剪切数据Bitmap bmap = data.getParcelableExtra("data");// 显示剪切的图像ImageView imageview = (ImageView)this.findViewById(R.id.imageview);imageview.setImageBitmap(bmap);// 图像保存到文件中FileOutputStream foutput = null;try {foutput = new FileOutputStream(this.imageFile);bmap.compress(Bitmap.CompressFormat.PNG, 100, foutput);} catch (FileNotFoundException e) {e.printStackTrace();}finally{if(null != foutput){try {foutput.close();} catch (IOException e) {e.printStackTrace();}}}}
- android 剪切图片
- android 图片剪切
- android图片剪切
- android 拍照剪切图片
- android 剪切图片
- Android图片操作-剪切
- android 剪切图片
- android 拍照 图片剪切
- Android 图片Bitmap的剪切
- Android 选择图片剪切上传
- Android 图片Bitmap的剪切
- Android图片居中缩放剪切
- android 剪切图片 显示图片的一部分
- Android实现图片剪切圆形效果
- Android 拍照获取图片并剪切
- android剪切成圆形图片CircleBitmap
- android 拍照和选择相册图片剪切
- android剪切圆角图片的方法
- mysql 添加用户访问权限
- 【转载】BitmapData的整理
- C#序列化与反序列化
- haXe2.1到haXe3的变化
- 【转载】NME不同平台上读写文件的处理
- android 剪切图片
- embed标签的使用
- 如何创建NME本地扩展
- 【程序7】数制转换
- haXe CFFI介绍
- 51单片机的学习心得
- 今天做错的笔试题:StringBuffer引用传参
- haXe中对BitmapData进行批量像素级运算
- 关于haXe NME中的事件机制