2011-01-31 71 views
1

我正在制作一个应用程序,发送从相机应用程序拍摄的照片,但它返回的图像似乎只是一个缩略图,我怎么能得到它来打开整个图像?在Android中使用相机应用程序时,如何返回整个图像而不仅仅是缩略图?

以下代码获取图像,但它太小。

public class OnTheJobActivity extends Activity{ 

private static final int CAMERA_PIC_REQUEST = 1337; 
private Button takePictureButton; 
private Button sendPictureButton; 
private Bitmap thumbnail; 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    this.setRequestedOrientation(
      ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
    setContentView(R.layout.onthejob); 
    takePictureButton = (Button) findViewById(R.id.takePictureButton); 
    takePictureButton.setOnClickListener(takePictureButtonListener); 
    sendPictureButton = (Button) findViewById(R.id.sendPictureButton); 
    sendPictureButton.setOnClickListener(sendPictureButtonListener); 


} 

protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (requestCode == CAMERA_PIC_REQUEST) { 
    thumbnail = (Bitmap) data.getExtras().get("data"); 
    ImageView image = (ImageView) findViewById(R.id.photoResultView); 
    image.setImageBitmap(thumbnail); 
    sendPictureButton.setVisibility(Button.VISIBLE); 
    } 
} 


private OnClickListener takePictureButtonListener = new OnClickListener() { 

    @Override 
    public void onClick(View arg0){ 
     Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
     startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST); 

    } 
    }; 

    private OnClickListener sendPictureButtonListener = new OnClickListener() { 

    @Override 
    public void onClick(View arg0){ 

     Intent i = new Intent(Intent.ACTION_SEND); 
     i.putExtra(Intent.EXTRA_EMAIL, "[email protected]"); 
     i.putExtra(Intent.EXTRA_SUBJECT,"On The Job"); 
     i.putExtra(Intent.EXTRA_STREAM, thumbnail); 
     i.setType("image/bmp"); 
     startActivity(Intent.createChooser(i,"Emailfile")); 

    } 
    }; 


} 
+0

愚蠢的问题,什么分辨率的图像是相机设置取? – Basic 2011-01-31 19:36:54

+0

它被采取高得多水库然后我回来,因此问题 – NickTFried 2011-02-01 01:14:52

回答

0

尝试使用所示here

具体实施:

Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() { 

    public void onPictureTaken(byte[] imageData, Camera c) { 

    } 

}; 
2

你也可以改变你使用的意图。

//in your buttonListener 
ContentValues values = new ContentValues(); 
imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); 
//create new Intent 
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
i.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); 

try{ 
    startActivityForResult(i, ACTIVITY_GET_IMAGE); 
} 
catch(Exception ex){ 
    Log.v("BRE", ex.toString()); 
} 
//in your activity 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 

    if(requestCode == ACTIVITY_GET_IMAGE){ 
     if(resultCode == RESULT_OK){ 
      try{String uri = data.getData().toString()} 
      catch(NullPointerException e){//do something} 
     } 
    } 
} 

这将返回一个URI,然后您可以用它来访问全分辨率图像