1

私は、ボタンを使ってカメラをロードし、その写真を自分のアプリに添付する必要があるアプリケーションを開発しています。私はカメラの読み込みに問題はありませんが、私は自分のアプリでカメラを使って撮影した写真を添付することができません。誰も良い解決策を与えることができますか?私のアプリケーションでカメラを使用して撮影した写真を添付するにはどうすればいいですか?

ありがとう(ありがとう) Swetha Kaulwar。

+0

? –

+0

どこに添付しますか? –

+0

私が作成したアプリケーションで。 –

答えて

2

私は私のonActivityResultでこれを行う...私は、キャプチャ意図から写真を取得する私は、これはあなたのproblen

に役立ちます願っています...そのサイズを小さくし、後でカスタムリストビューに追加されたリストに追加
if (resultCode == Activity.RESULT_OK) { 

      Bundle extras = intent.getExtras(); 
      Bitmap bitmap = (Bitmap) extras.get("data"); 


      int width = bitmap.getWidth(); 
      Log.i("size width:", String.valueOf(width)); 
      int height = bitmap.getHeight(); 
      Log.i("size height:", String.valueOf(height)); 

      float widthPercent = (float) 0.8; 
      float heightPercent = (float) 0.8; 

      float newWidth = bitmap.getWidth() * widthPercent; 
      float newHeight = bitmap.getHeight() * heightPercent; 

      while (newWidth > 250 || newHeight > 250) { 

      newWidth = newWidth * widthPercent; 
      Log.i("size width:", String.valueOf(newWidth)); 
      newHeight = newHeight * heightPercent; 
      Log.i("size height:", String.valueOf(newHeight)); 
      } 




      // calculate the scale - in this case = 0.4f 
      float scaleWidth = ((float) newWidth)/width; 
      Log.i("new size width:", String.valueOf(scaleWidth)); 
      float scaleHeight = ((float) newHeight)/height; 
      Log.i("new size height:", String.valueOf(scaleHeight)); 

      Matrix matrix = new Matrix(); 

      // resize the bit map 
      matrix.postScale(scaleWidth, scaleHeight); 

      // recreate the new Bitmap 
      Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, 
      width, height, matrix, true); 

      Log.i("new bitmap width:", 
      String.valueOf(resizedBitmap.getWidth())); 
      Log.i("new bitmap height:", 
      String.valueOf(resizedBitmap.getHeight())); 

      App.serviceCallImages.add(resizedBitmap); 

      Adapter.notifyDataSetChanged(); 

      break; 
     } 

はHERESに私のカメラの意図コード付け

public void OnCameraOpen(View v) { 

    if (App.serviceCallImages.size() < 2) { 
     Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 

     startActivityForResult(intent, CAPTURE_PICTURE_INTENT); 
    } else { 
     Toast.makeText(getApplicationContext(), getString(R.string.MaxPics), 
       Toast.LENGTH_SHORT).show(); 
    } 

} 
関連する問題