当使用Android的相机应用,我怎么可以返回整个图像而不只是缩略图? [英] When using the Camera app in Android, how can I return the whole image instead of just the thumbnail?
本文介绍了当使用Android的相机应用,我怎么可以返回整个图像而不只是缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在发送从摄像机应用拍摄的照片但它返回的形象似乎我怎样才能得到它把整个图像只是一个缩略图的应用程序?
以下code得到的图像,但它太小了。
公共类OnTheJobActivity延伸活动{ 私有静态最终诠释CAMERA_PIC_REQUEST = 1337;
私人按钮takePictureButton;
私人按钮sendPictureButton;
私人位图的缩略图; / **当第一次创建活动调用。 * /
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
this.setRequestedOrientation(
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
的setContentView(R.layout.onthejob);
takePictureButton =(按钮)findViewById(R.id.takePictureButton);
takePictureButton.setOnClickListener(takePictureButtonListener);
sendPictureButton =(按钮)findViewById(R.id.sendPictureButton);
sendPictureButton.setOnClickListener(sendPictureButtonListener);
} 保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
如果(要求code == CAMERA_PIC_REQUEST){
。缩略图=(位图)data.getExtras()获得(数据);
ImageView的图像=(ImageView的)findViewById(R.id.photoResultView);
image.setImageBitmap(缩略图);
sendPictureButton.setVisibility(Button.VISIBLE);
}
}
私人OnClickListener takePictureButtonListener =新OnClickListener(){ @覆盖
公共无效的onClick(查看为arg0){
意图cameraIntent =新意图(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent,CAMERA_PIC_REQUEST); }
}; 私人OnClickListener sendPictureButtonListener =新OnClickListener(){ @覆盖
公共无效的onClick(查看为arg0){ 意图I =新意图(Intent.ACTION_SEND);
i.putExtra(Intent.EXTRA_EMAILabc@gmail.com);
i.putExtra(Intent.EXTRA_SUBJECT,在职);
i.putExtra(Intent.EXTRA_STREAM,缩略图);
i.setType(图像/ BMP);
startActivity(Intent.createChooser(ⅰEmailfile)); }
};
}
解决方案
尝试使用所示的这里
具体做法是:
Camera.PictureCallback mPictureCallback =新Camera.PictureCallback(){ 公共无效onPictureTaken(字节[]为imageData,相机C){ }};
I am making an app that sends a picture taken from the Camera app however the image it returns seems to be only a thumbnail how can I get it to turn the whole image?
The following code gets an image, but it's too small.
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, "abc@gmail.com");
i.putExtra(Intent.EXTRA_SUBJECT,"On The Job");
i.putExtra(Intent.EXTRA_STREAM, thumbnail);
i.setType("image/bmp");
startActivity(Intent.createChooser(i,"Emailfile"));
}
};
}
解决方案
Try using the implementation shown here
Specifically:
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] imageData, Camera c) {
}
};
这篇关于当使用Android的相机应用,我怎么可以返回整个图像而不只是缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文