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

解决方案 »

  1.   

    在 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;
    }
      

  2.   

    不需要手动的话 也可以用BitmapFactory
      

  3.   

    回1楼的,我拍照的方法中,没有Bitmap data这个参数,我拍照的方法和onActivityResult方法如下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);
    }protected void onActivityResult(int requestCode, int resultCode, Intent data) 

    super.onActivityResult(requestCode, resultCode, data); 
    if (resultCode == RESULT_OK)

    if(requestCode==REQ_CODE_CAMERA)
    { }} 
    }你再帮我看下怎么弄 thanks
      

  4.   

    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Imagefile);保存的是图片的路径在你的onActivityResult方法中,通过URI读取,作为BitmapFactory的参数
      

  5.   

    2 楼和6楼的,
    BitmapFactory 怎么用呀,在onActivityResult方法中,怎么弄呀,
      

  6.   

    此功能已完成 
    本人email  [email protected]