gpt4 book ai didi

android - 从互联网网址加载图片,有些图片旋转了 90 度

转载 作者:行者123 更新时间:2023-12-05 07:49:54 29 4
gpt4 key购买 nike

如何识别从url加载的图片是旋转的?

我有一个来自 url 的图像列表,一些加载的图像与原始图像相比旋转了 90 度。

最佳答案

给你。如果它处于横向模式,这将重新定位您的图像:

int width = bitmap.getWidth();
int height = bitmap.getHeight();

if (width > height){
rotatedBitmap = rotate(bitmap,-90)
}


private Bitmap rotate(Bitmap bm, int rotation) {
if (rotation != 0) {
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
Bitmap bmOut = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
return bmOut;
}
return bm;
}

关于android - 从互联网网址加载图片,有些图片旋转了 90 度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36810420/

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