2014-11-06 17 views
0

我想打開我的相機應用程序,並獲取圖像到imageview.Even當我使用wrapview內容的imageview的寬度和高度,它顯示爲一個縮略圖。我已經看到了幾個職位的大小調整,我不知道哪一個使用。問題是,我想要的圖像,因爲它是,它的全尺寸,而不是一個縮略圖。以下是我有什麼嘗試:從相機意圖獲取位圖圖像作爲縮略圖。如何使其更大

inside a button click event: 

Intent cameraIntent = new Intent(
       android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 

     startActivityForResult(cameraIntent, 111); 


@Override 
     protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
      // TODO Auto-generated method stub 

      if (resultCode == RESULT_OK && requestCode == 111) { 
       Bitmap photo = (Bitmap) data.getExtras().get("data"); 
       preview.setImageBitmap(photo); 
} 

我試圖顯示圖像作爲imageview.The問題是我想要一個更大的image.When我嘗試改變的ImageView的widht和高度300像素和150像素內的預覽,我得到一個空白。

我如何獲得更大的圖像?

編輯:

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); 
     File file = new File(Environment.getExternalStorageDirectory()+File.separator + "image.jpg"); 
     intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); 
     startActivityForResult(intent, CAPTURE_IMAGE_FULLSIZE_ACTIVITY_REQUEST_CODE); 

在對活動的結果:

if (requestCode == CAPTURE_IMAGE_FULLSIZE_ACTIVITY_REQUEST_CODE) 
        { 
         //Get our saved file into a bitmap object: 
         File file = new File(Environment.getExternalStorageDirectory()+File.separator + "image.jpg"); 
         Bitmap bitmap = decodeSampledBitmapFromFile(file.getAbsolutePath(), 1000, 700); 
         preview.setImageBitmap(bitmap); 
        } 

public static Bitmap decodeSampledBitmapFromFile(String path, int reqWidth, int reqHeight) 
     { // BEST QUALITY MATCH 

      //First decode with inJustDecodeBounds=true to check dimensions 
      final BitmapFactory.Options options = new BitmapFactory.Options(); 
      options.inJustDecodeBounds = true; 
      BitmapFactory.decodeFile(path, options); 

      // Calculate inSampleSize, Raw height and width of image 
      final int height = options.outHeight; 
      final int width = options.outWidth; 
      options.inPreferredConfig = Bitmap.Config.RGB_565; 
      int inSampleSize = 1; 

      if (height > reqHeight) 
      { 
       inSampleSize = Math.round((float)height/(float)reqHeight); 
      } 
      int expectedWidth = width/inSampleSize; 

      if (expectedWidth > reqWidth) 
      { 
       //if(Math.round((float)width/(float)reqWidth) > inSampleSize) // If bigger SampSize.. 
       inSampleSize = Math.round((float)width/(float)reqWidth); 
      } 

      options.inSampleSize = inSampleSize; 

      // Decode bitmap with inSampleSize set 
      options.inJustDecodeBounds = false; 

      return BitmapFactory.decodeFile(path, options); 
     } 

但我仍然會得到相同的尺寸。

回答

0

您必須提供一個putExtra選項和一個文件名以存儲它的位置。額外的數據只是一個快照。

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(filePath))); 

它會保存圖片到指定的位置(只要它是可寫,這樣)

+0

我已經試過了,但現在我想增加size.So我做了一些changes.REFER編輯 – 2014-11-06 12:32:34