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
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
解决方案 »
- android项目中的bin目录下的奇怪现象
- Re-installation failed due to different application signatures.
- android如何获取手指在TextView上面滑动的距离?
- 急!!!请教一个有关布局文件的问题???
- Android 提示:No such file or directory 没找到文件 目录
- edittext 翻页例子谁有
- 关于在linux下编译android项目遇到的一个问题
- ProgressDialog添加一个取消键,点击后停止加载
- 写了个行车记录仪软件
- Android如何将Activity的布局嵌套到Fragment布局里
- onActivityResult 中取参数值,在线等
- android上传图片不成功,在线等
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;
}
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);
}protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK)
{
if(requestCode==REQ_CODE_CAMERA)
{ }}
}你再帮我看下怎么弄 thanks
BitmapFactory 怎么用呀,在onActivityResult方法中,怎么弄呀,
本人email [email protected]