加载从互联网网址的图像,有些旋转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;
}
如果它们是JPEG,请查找EXIF'方向'标题。股票的Android代码,比如'BitmapFactory',忽略了这一点,尽管一些图片加载库可能会关注这个头文件(毕加索?)。 – CommonsWare