Bitmap.createBitmap() matrix filter 参数

       Bitmap b= BitmapFactory.decodeFile("/sdcard/1.jpg");
        Matrix matrix=new Matrix();
        matrix.postScale(0.5f,0.5f);
        Bitmap  bitmap = Bitmap.createBitmap(b,0,0,b.getWidth(),b.getHeight(),matrix,true);
        //最后一个参数如果为true,生成的bitmap的大小会比用false小一点,清晰度感觉会差一些,但不是很大,连贯性会比较好,像素之间过渡得比较好,看着柔和一些。
        //false或者true,其实相差很小
        try {
            File pictureFile = new File("/sdcard/15.jpg");
            FileOutputStream fos = new FileOutputStream(pictureFile);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
            fos.flush();
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

mm

 

 

true if the source should be filtered. Only applies if the matrix contains more than just translation.
当进行的不只是平移变换时,filter参数为true可以进行滤波处理,有助于改善新图像质量;flase时,计算机不做过滤处理。
 

你可能感兴趣的:(Android,android,studio,安卓系统开发)