📌  相关文章
📜  如何以编程方式在 android 中调整图像大小 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:35.234000             🧑  作者: Mango

代码示例1
public static Bitmap resizeImage(Bitmap realImage, float maxImageSize,
        boolean filter) {
    float ratio = Math.min(
            (float) maxImageSize / realImage.getWidth(),
            (float) maxImageSize / realImage.getHeight());
    int width = Math.round((float) ratio * realImage.getWidth());
    int height = Math.round((float) ratio * realImage.getHeight());

    Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
            height, filter);
    return newBitmap;
}