Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 保存在SD卡上的图像看起来更大_Android - Fatal编程技术网

Android 保存在SD卡上的图像看起来更大

Android 保存在SD卡上的图像看起来更大,android,Android,我正在SD卡上保存宽度为30px,高度为30px,文件类型为png的小图像。保存图像后,当我在SD卡上查看它时,图像会以低分辨率显示得更大。然而,原始图像非常清晰。下面是我的代码,请告诉我如何才能使图像质量更好,也让图像是它的原始大小,而不是看起来更大。谢谢 Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.b_01); ByteArrayOutputStream bStream1 = new B

我正在SD卡上保存宽度为30px,高度为30px,文件类型为png的小图像。保存图像后,当我在SD卡上查看它时,图像会以低分辨率显示得更大。然而,原始图像非常清晰。下面是我的代码,请告诉我如何才能使图像质量更好,也让图像是它的原始大小,而不是看起来更大。谢谢

 Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.b_01);

    ByteArrayOutputStream bStream1 = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.PNG, 100, bStream1);

File f1 = new File(Environment.getExternalStorageDirectory() + File.separator + "AppName" + "/bmp.png");
    if(!f1.exists()) {
        try {

            f1.createNewFile();
            FileOutputStream fs1 = new FileOutputStream(f1);
            fs1.write(bStream1.toByteArray());
            fs1.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

如果这是您正在保存的唯一图像,请在SD卡中保存位图之前设置其宽度和高度。如何设置图像的宽度和高度,是否缩放图像?不必设置宽度和高度。您最好检查bmp.getWidth()和bmp.getHeight()是否是您认为在decodeResource()之后的值。