图片保存太小为什么?

时间:2021-09-28 20:22:01

i want to take an image with the camera and save it into pictures folder... the only thing that i cannot resolve is why my image is saved in a small size...

我想用相机拍摄图像并将其保存到图片文件夹中...我唯一无法解决的是为什么我的图像以小尺寸保存...

Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(i, TAKE_PICTURE);

Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(i,TAKE_PICTURE);

protected void onActivityResult(int requestCode, int resultCode, Intent imageReturned) { super.onActivityResult(requestCode, resultCode, imageReturned);

protected void onActivityResult(int requestCode,int resultCode,Intent imageReturned){super.onActivityResult(requestCode,resultCode,imageReturned);

        switch(requestCode) {
      case TAKE_PICTURE:
             if(resultCode == RESULT_OK)
                { ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                 photo.compress(Bitmap.CompressFormat.PNG, 100, bytes);                 

                 File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)+ File.separator + "test3.png");
                 try {
                    f.createNewFile();
                    //write the bytes in file
                     FileOutputStream fo = new FileOutputStream(f);
                     fo.write(bytes.toByteArray());
                     fo.flush();
                     // remember close de FileOutput
                     fo.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                 }
                        }
                      }

1 个解决方案

#1


8  

You should consider reading the documentation:

您应该考虑阅读文档:

http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE

http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE

It always give you a smaller image unless you set it to give you full sized:

它总是会给你一个较小的图像,除非你设置它给你全尺寸:

Directly from the Dev Site

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. 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_OUTPUT不存在,则在额外字段中返回小尺寸图像作为Bitmap对象。这对于只需要小图像的应用程序非常有用。如果存在EXTRA_OUTPUT,则将将全尺寸图像写入EXTRA_OUTPUT的Uri值。

#1


8  

You should consider reading the documentation:

您应该考虑阅读文档:

http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE

http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE

It always give you a smaller image unless you set it to give you full sized:

它总是会给你一个较小的图像,除非你设置它给你全尺寸:

Directly from the Dev Site

The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT is not present, then a small sized image is returned as a Bitmap object in the extra field. 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_OUTPUT不存在,则在额外字段中返回小尺寸图像作为Bitmap对象。这对于只需要小图像的应用程序非常有用。如果存在EXTRA_OUTPUT,则将将全尺寸图像写入EXTRA_OUTPUT的Uri值。