<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)  編輯  收藏 所屬分類: JavaAndroid
    主站蜘蛛池模板: 国产精品免费看久久久| 美女裸免费观看网站| 亚洲综合激情另类小说区| 亚洲精品午夜视频| 嫩草影院在线播放www免费观看| 全部免费a级毛片| 亚洲中文字幕无码爆乳AV| 亚洲AV区无码字幕中文色| 亚洲国产品综合人成综合网站| 精品在线观看免费| 免费黄色网址网站| 免费在线观看a级毛片| 亚洲av无码专区在线电影天堂| a在线视频免费观看| 大学生美女毛片免费视频| 国产亚洲一区二区在线观看| 亚洲日韩国产一区二区三区在线| 一级一看免费完整版毛片| 免费三级毛片电影片| 久久久久亚洲AV综合波多野结衣 | 欧洲亚洲国产精华液| 国产一区二区三区在线免费| 麻豆成人久久精品二区三区免费| 亚洲综合中文字幕无线码| 猫咪www免费人成网站| 伊人久久综在合线亚洲91| 暖暖免费日本在线中文| 亚洲AV无码乱码在线观看代蜜桃| 久操视频在线免费观看| 亚洲午夜精品在线| 亚洲国产91精品无码专区| 亚洲国产精品精华液| 国产美女在线精品免费观看| 亚洲第一精品在线视频| 毛片a级毛片免费播放100| 亚洲一区电影在线观看| 国产成人免费永久播放视频平台 | 中文字幕中韩乱码亚洲大片| 97在线视频免费| 亚洲欧洲免费视频| 国产无遮挡无码视频免费软件 |