专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Android

拍照成功,可怎么限图大小

发布时间:2010-05-30 10:56:50 文章来源:www.iduyao.cn 采编人员:星星草
拍照成功,可如何限图大小,在线等
android代码中,拍照用的是下面的代码
public void ImageCapture() {
File DatalDir = Environment.getExternalStorageDirectory();
File myDir = new File(DatalDir, "/DCIM/Camera");
myDir.mkdirs();
String mDirectoryname = DatalDir.toString() + "/DCIM/Camera";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd-hhmmss",
Locale.SIMPLIFIED_CHINESE);
tempfile = new File(mDirectoryname, sdf.format(new Date())
+ ".jpg");
if (tempfile.isFile())
tempfile.delete();
Uri Imagefile = Uri.fromFile(tempfile);
   
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Imagefile);
startActivityForResult(cameraIntent, REQ_CODE_CAMERA);
}

现如何控制图的长与宽呢,thanks

------解决方案--------------------
在 onActivityResult 中先调用裁剪
public static Intent getCropCremaImageIntent(Bitmap data) {
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setType("image/*");
intent.putExtra("data", data);
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 180);
intent.putExtra("outputY", 180);
intent.putExtra("return-data", true);
return intent;
}
------解决方案--------------------
不需要手动的话 也可以用BitmapFactory
------解决方案--------------------
获得机器可以支持的尺寸,选一个你要的,保存就可以了
------解决方案--------------------
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Imagefile);保存的是图片的路径

在你的onActivityResult方法中,通过URI读取,作为BitmapFactory的参数
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: