android - 图片保存太小,为什么?

标签 android image

我想用相机拍照存到图片文件夹里。。。唯一无法解决的是为什么我的图片保存的是小尺寸的。。。。

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);

    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();
                }    
            }
    }
}

最佳答案

您应该考虑阅读文档:

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

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

直接来自开发站点

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.

关于android - 图片保存太小,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14695710/

相关文章:

android - 通过 native C 从 list 中读取 Android 权限

java - 按颜色类型调整图像饱和度

android - 如何滚动到 android TextView 的末尾?

java - 每次应用程序启动时 AlarmManager 都会触发

android - Android 4 中的雅虎货币汇率

Android 在不保留宽高比的情况下将图像适配到 ImageView

c - 如何使用 libpng 将 C 代码中的 png 图像解码为原始字节?

iphone - 像素配色估计

php获取图像名称并添加到数据库?

image - Image::ValidJpeg 和内存文件的段错误