现在的位置: 首页 > 综合 > 正文

Android 图片放大缩小的源代码

2013年04月26日 ⁄ 综合 ⁄ 共 412字 ⁄ 字号 评论关闭

// 放大缩小图片
    public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) {
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        Matrix matrix = new Matrix();
        float scaleWidht = ((float) w / width);
        float scaleHeight = ((float) h / height);
        matrix.postScale(scaleWidht, scaleHeight);
        Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height,
                matrix, true);
        return newbmp;
    }

抱歉!评论已关闭.