gpt4 book ai didi

android - 如何将Image的选定区域设置为ImageView

转载 作者:太空狗 更新时间:2023-10-29 13:25:27 24 4
gpt4 key购买 nike

我试图将图像设置为来自外部存储的 imageimageviewview,我完成了,但问题是它将整个图像设置为 imageview 并且我只想从该图像设置选定的方形区域。 Just life facebook 提供了设置个人资料图片的功能。任何人都可以帮我做吗??以下是我想要做的示例..

enter image description here

最佳答案

像这样:

public static Bitmap cropBitmapToSquare(Bitmap bmp) {

System.gc();
Bitmap result = null;
int height = bmp.getHeight();
int width = bmp.getWidth();
if (height <= width) {
result = Bitmap.createBitmap(bmp, (width - height) / 2, 0, height,
height);
} else {
result = Bitmap.createBitmap(bmp, 0, (height - width) / 2, width,
width);
}
return result;
}

这是一个具有裁剪 active 的样本:

http://khurramitdeveloper.blogspot.ru/2013/07/capture-or-select-from-gallery-and-crop.html

关于android - 如何将Image的选定区域设置为ImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21701447/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com