android 把.bmp文件自定义放大

 public Bitmap bigSize(Bitmap b, float Bigwidth, float Bigheight) {
    
    
        int width= b.getWidth();
        int height= b.getHeight();
        float sx = (float) Bigwidth/ width;//要强制转换,不转换我的在这总是死掉。
        float sy = (float) Bigheight/ height;
        Matrix matrix = new Matrix();
        matrix.postScale(sx, sy); // 长和宽放大缩小的比例
        Bitmap resizeBmp = Bitmap.createBitmap(b, 0, 0, width, height, matrix, true);
        return resizeBmp;
    }

这里的Bigwidth,Bigheight是指你想要放到到多少像素即放大后的长,宽是多少

猜你喜欢

转载自blog.csdn.net/m0_49412847/article/details/122495201