• 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);               
          }       
          }           
          }

  • 相关阅读:
    实验四 决策树算法及应用
    实验三 朴素贝叶斯算法及应用
    实验二 K-近邻算法及应用
    实验一 感知器及其应用
    实验三
    实验二 结构化分析与设计
    实验一 Visio的使用
    ATM管理系统
    流程图与活动图的区别与联系
    四则运算
  • 原文地址:https://www.cnblogs.com/zhwl/p/2184681.html
Copyright © 2020-2023  润新知