如何判断从url加载的图片是否旋转?
我有一组来自url的图片列表,其中有些加载的图片与原始图片相比旋转了90度。
我有一组来自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;
}