<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
    主站蜘蛛池模板: 亚洲狠狠爱综合影院婷婷| 处破痛哭A√18成年片免费| 国产精品亚洲精品久久精品| 中文字幕免费高清视频| 成年人免费的视频| 久久久无码精品亚洲日韩京东传媒| 免费一级毛片无毒不卡| 亚洲国产成人久久综合碰碰动漫3d| 久久精品乱子伦免费| 亚洲午夜精品一区二区| 免费无码一区二区三区| 亚洲国产视频网站| 好吊妞视频免费视频| 国产精品亚洲精品日韩动图| 国产精品亚洲综合一区| 免费一级毛片在线播放视频| 亚洲人成高清在线播放| 好吊妞在线成人免费| 曰韩无码AV片免费播放不卡| 国产亚洲精品无码成人| 久草视频在线免费| 亚洲第一成年免费网站| 亚洲午夜无码AV毛片久久| 国产免费AV片在线观看| 亚洲资源最新版在线观看| 国产精品国产午夜免费福利看| 无码免费又爽又高潮喷水的视频| 国产AV无码专区亚洲AV男同| 亚洲免费视频网址| 羞羞视频免费观看| 伊人久久综在合线亚洲2019| 女人18特级一级毛片免费视频| 日韩精品无码免费视频| 4480yy私人影院亚洲| 国产乱子伦精品免费无码专区 | 四虎影视无码永久免费| 91亚洲国产在人线播放午夜| 日韩视频免费在线| 日韩插啊免费视频在线观看 | 亚洲人成网站999久久久综合| 亚洲精品成人a在线观看|