<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-348  評論-598  文章-0  trackbacks-0

     

    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(), nullnull));                               
                     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);                
          }
            
          }
                
          }
     


    http://code.google.com/p/android/issues/detail?id=1480
    討論的很有意義
    Well, now on 1.5, the documentation has been updated: "If the EXTRA_OUTPUT is not
    present, then a small sized image is returned as a Bitmap object in the extra field.
    If the EXTRA_OUTPUT is present, then the full-sized image will be written to
    the Uri value of EXTRA_OUTPUT."

    But using the following piece of code:

        private void takePic2() {
            Intent imageCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
    Uri.fromFile(new File(FILE_PATH)));
            startActivityForResult(imageCaptureIntent, 1);
        }
    The doc says:
    1/ "If the EXTRA_OUTPUT is not present, then a small sized image is returned"
    2/ "If the EXTRA_OUTPUT is present, then the *full-sized* image will be written"

    Alas 2/ is not true, it produces a 512x384 image - that is not "full sized".

    private void doTakePhotoAction() {    
        
    // http://hfoss.org/Tutorial:Camera_and_Gallery_Demo    
        
    // http://stackoverflow.com/questions/1050297/how-to-get-the-url-of-the-captured-image    
        
    // http://www.damonkohler.com/2009/02/android-recipes.html    
        
    // http://www.firstclown.us/tag/android/    
        
    // The one I used to get everything working: http://groups.google.com/group/android-developers/msg/2ab62c12ee99ba30     
        
        Intent intent 
    = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);    
        
        
    //Wysie_Soh: Create path for temp file    
        mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),    
                            
    "tmp_contact_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));    
        
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);    
        
        
    try {    
            intent.putExtra(
    "return-data"true);    
            startActivityForResult(intent, PICK_FROM_CAMERA);    
        }
     catch (ActivityNotFoundException e) {    
            
    //Do nothing for now    
        }
        
    }
        
        
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {    
        
    if (resultCode != RESULT_OK) {    
            
    return;    
        }
        
        
        
    switch (requestCode) {    
        
        
    case CROP_FROM_CAMERA: {    
            
    //Wysie_Soh: After a picture is taken, it will go to PICK_FROM_CAMERA, which will then come here    
            
    //after the image is cropped.    
        
            
    final Bundle extras = data.getExtras();    
        
            
    if (extras != null{    
                Bitmap photo 
    = extras.getParcelable("data");    
        
                mPhoto 
    = photo;    
                mPhotoChanged 
    = true;    
                mPhotoImageView.setImageBitmap(photo);    
                setPhotoPresent(
    true);    
            }
        
        
            
    //Wysie_Soh: Delete the temporary file                            
            File f = new File(mImageCaptureUri.getPath());                
            
    if (f.exists()) {    
                f.delete();    
            }
        
        
            InputMethodManager mgr 
    = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);    
            mgr.showSoftInput(mPhotoImageView, InputMethodManager.SHOW_IMPLICIT);    
        
            
    break;    
        }
        
        
        
    case PICK_FROM_CAMERA: {    
            
    //Wysie_Soh: After an image is taken and saved to the location of mImageCaptureUri, come here    
            
    //and load the crop editor, with the necessary parameters (96x96, 1:1 ratio)    
        
            Intent intent 
    = new Intent("com.android.camera.action.CROP");    
            intent.setClassName(
    "com.android.camera""com.android.camera.CropImage");    
        
            intent.setData(mImageCaptureUri);    
            intent.putExtra(
    "outputX"96);    
            intent.putExtra(
    "outputY"96);    
            intent.putExtra(
    "aspectX"1);    
            intent.putExtra(
    "aspectY"1);    
            intent.putExtra(
    "scale"true);    
            intent.putExtra(
    "return-data"true);                
            startActivityForResult(intent, CROP_FROM_CAMERA);    
        
            
    break;    
        
        }
        
        }
        
    }
       



    ---------------------------------------------------------
    專注移動開發

    Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
    posted on 2010-01-12 17:37 TiGERTiAN 閱讀(2518) 評論(0)  編輯  收藏 所屬分類: Java 、Android
    主站蜘蛛池模板: 一级做a免费视频观看网站| 最新仑乱免费视频| 蜜桃成人无码区免费视频网站| 国内精品一级毛片免费看| 91九色老熟女免费资源站| 国产精品永久免费10000| 成人免费无码大片a毛片| 国产亚洲A∨片在线观看| 亚洲国产成人久久| 国产99久久久久久免费看| 亚欧日韩毛片在线看免费网站| 国产福利在线免费| 久久久综合亚洲色一区二区三区 | 成人看的午夜免费毛片| 亚洲成人影院在线观看| 亚洲国产综合精品中文第一| 鲁啊鲁在线视频免费播放| **aaaaa毛片免费同男同女| 亚洲一区二区三区偷拍女厕| 67194在线午夜亚洲| 久久99精品视免费看| 成年在线网站免费观看无广告| 精品亚洲成AV人在线观看| 一级毛片视频免费| 日本a级片免费看| 综合一区自拍亚洲综合图区| aⅴ在线免费观看| 亚洲黄色网站视频| 好久久免费视频高清| 久久青草亚洲AV无码麻豆| 成在线人免费无码高潮喷水| 亚洲伊人久久成综合人影院| 一级毛片免费一级直接观看| 国产乱子影视频上线免费观看| 亚洲AV成人无码久久WWW| 精品久久久久久久免费人妻| 亚洲欧美成人一区二区三区| 成人免费无码大片A毛片抽搐| 亚洲综合色丁香婷婷六月图片| 免费看片免费播放| 理论亚洲区美一区二区三区|