2017-08-23 9 views
1

に(cuptured画像の)ビットマップファイルを変換するフォトパラメータはビットマップであると私はそれをチェックし、それは私がすることができますので、私はパスにビットマップを変換することができますどのようにパスファイル

cuptured画像を示しています

protected void onCreate(Bundle savedInstanceState) { 

    super.onCreate(savedInstanceState); 
    setContentView(R.layout.opencvhc); 
    ImgPhoto = (ImageView) findViewById(R.id.ImgPhoto); 
    Bundle extras = getIntent().getExtras(); 
    if (extras != null) { 
     bm = (BitmapDataObject) getIntent().getSerializableExtra("photo"); //Obtaining data 
     bitmap = bm.getBip(); 
     ImgPhoto.setImageBitmap(bitmap); 
    } 

    Checkmood = (Button) findViewById(R.id.Checkmood); 
    Check = (Button) findViewById(R.id.Check); 
    txtView = (TextView) findViewById(R.id.txt); 


} 

public void CheckClick(View view) throws IOException { 

    String file = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "file", null); 
    //Uri screenshotUri = Uri.parse(file); 
    Toast.makeText(OpenCVhc.this, file, Toast.LENGTH_SHORT).show(); 
    final Intent emailIntent1 = new Intent(android.content.Intent.ACTION_SEND); 
    emailIntent1.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"}); 
    emailIntent1.putExtra(Intent.EXTRA_SUBJECT, "Image processing picture"); 
    emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    // emailIntent1.putExtra(Intent.EXTRA_STREAM, screenshotUri); 
    emailIntent1.putExtra(Intent.EXTRA_TEXT, "" + 
      "We checked your photo with the Ecg-Leads \n 1) : " + 
      "\n the image proccessing ___ "); 
    emailIntent1.setType("image/png"); 
    try { 
     startActivity(Intent.createChooser(emailIntent1, "Send mail...")); 
    } catch (android.content.ActivityNotFoundException ex) { 
     Toast.makeText(OpenCVhc.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); 
    } 

} 

}

+0

イメージキャプチャコードを投稿できますか? –

答えて

0

このソリューションを参照し、「WRITE_EXTERNAL_STORAGE」権限befoをチェックすることを忘れないでください:これはコードです

メールに添付ファイルとして送信ファイルに書き直す。 リファレンス:Android: Saving Bitmap to External Memory

public void saveImageToExternalStorage(Bitmap finalBitmap) { 
    String root =Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString(); 
    File myDir = new File(root + "/saved_images"); 
    myDir.mkdirs(); 
    Random generator = new Random(); 
    int n = 10000; 
    n = generator.nextInt(n); 
    String fname = "Image-" + n + ".jpg"; 
    File file1 = new File(myDir, fname); 
    if (file1.exists()) 
     file1.delete(); 
    try { 
     FileOutputStream out = new FileOutputStream(file1); 
     finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); 
     out.flush(); 
     out.close(); 
    } 
    catch (Exception e) { 
     e.printStackTrace(); 
    } 


    // Tell the media scanner about the new file so that it is 
    // immediately available to the user. 
    MediaScannerConnection.scanFile(this, new String[] { file1.toString() },    null, 
      new MediaScannerConnection.OnScanCompletedListener() { 
       public void onScanCompleted(String path, Uri uri) { 
        Log.i("ExternalStorage", "Scanned " + path + ":"); 
        Log.i("ExternalStorage", "-> uri=" + uri); 
       } 
      }); 

} 
関連する問題