Android 简单的图片缩放方法

很简单的一个图片缩放方法,注意要比例设置正确否则可能会内存溢出

相关问题 java.lang.IllegalArgumentException: bitmap size exceeds 32bits 可查看 http://blog.csdn.net/zhouzme/article/details/21732095


    public static Bitmap scale(Bitmap bitmap, float scaleWidth, float scaleHeight) {
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        Matrix matrix = new Matrix();
        matrix.postScale(scaleWidth, scaleHeight);
        Log.i(TAG, "scaleWidth:"+ scaleWidth +", scaleHeight:"+ scaleHeight);
        return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    }


posted @ 2014-03-21 17:21  神神的蜗牛  阅读(266)  评论(0编辑  收藏  举报