简体   繁体   English

如何获得高分辨率图像

[英]How to get a high resolution image

My problem is, when I take a picture from camera and passing to another activity. 我的问题是,当我从相机拍摄照片并传递到其他活动时。 The image is not in high resolution. 图像不是高分辨率的。 How can I make my image in high resolution. 如何以高分辨率制作图像。 my codes below 我的以下代码

Main Activity 主要活动

    Button btn_cam = (Button) findViewById(R.id.btn_cam);
    btn_cam.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            MainActivity.this.startActivityForResult(intent, CAMERA_PIC_REQUEST);

        }
    });
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) {

        Bitmap image = (Bitmap) data.getExtras().get("data");
        Intent cam = new Intent(this, MainCam.class);
        cam.putExtra("flostic", image);
        startActivity(cam);

Second Activity 第二次活动

            Intent intent = getIntent();
            imageBitmap = (Bitmap) intent.getParcelableExtra("flostic");

Add an MediaStore.EXTRA_OUTPUT to the intent,and give path in putExtra to specify path for picture saving, because otherwise it only returns a snap of picture not a high resuolution picture. MediaStore.EXTRA_OUTPUT添加到该意图中,并在putExtra提供路径以指定图片保存路径,因为否则,它仅返回图片快照而不是高分辨率图片。 Refer this doc . 请参阅此文档

Standard Intent action that can be sent to have the camera application capture an image and return it. 可以发送以使相机应用程序捕获图像并将其返回的标准Intent动作。 The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. 调用方可以传递一个额外的EXTRA_OUTPUT来控制该图像的写入位置。 If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. 如果不存在EXTRA_OUTPUT,则会在Extra字段中将一个小型图像作为Bitmap对象返回。 This is useful for applications that only need a small image. 这对于只需要较小图像的应用程序很有用。 If the EXTRA_OUTPUT is present, then the full-sized image will be written to the Uri value of EXTRA_OUTPUT . 如果存在EXTRA_OUTPUT ,则将全尺寸图像写入EXTRA_OUTPUTUri值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM