android 照相以及关于自动生成的图片分辨率和面积太小问题 (转)

第一步:

String SD_CARD_TEMP_DIR = Environment.getExternalStorageDirectory() + File.separator + "tmpPhoto.jpg";
Intent takePictureFromCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureFromCameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new   File(SD_CARD_TEMP_DIR)));
startActivityForResult(takePictureFromCameraIntent, TAKE_PICTURE_WITH_CAMERA);

第二步:
public void onActivityResult(int requestCode, int resultCode, Intent data) {       
super.onActivityResult(requestCode, resultCode, data);       
//      Picture taken from camera       
  if (requestCode == TAKE_PICTURE_WITH_CAMERA) {               
     if (resultCode == Activity.RESULT_OK) {                      
       // http://code.google.com/p/android/issues/detail?id=1480                       
       //Toast.makeText(AddPhotos.this, "" + data, Toast.LENGTH_SHORT).show();                      
        // on activity return                      
         File f = new File(SD_CARD_TEMP_DIR);                      
          try {                           
                Uri capturedImage =     Uri.parse(android.provider.MediaStore.Images.Media.insertImage(getContentResolver(),  f.getAbsolutePath(), null, null));                              
                 Log.i("camera", "Selected image: " + capturedImage.toString());                           
                 f.delete();                       
                 }
         catch (FileNotFoundException e) {                           
         // TODO Auto-generated catch block                          
          e.printStackTrace();                       
          }              
           }               
      else {                       
      Log.i("Camera", "Result code was " + resultCode);               
      }       
      }           
      }

posted @ 2011-09-22 08:55  郑文亮  阅读(1711)  评论(0编辑  收藏  举报