RecyclerViewで異なる画像を読み込み、Picassoを使用してインターネットから取得しますが、iPhoneからの画像が逆さまになってしまい、その理由がわかりません。
インターネットで正常に見えます。ピカソを使用するとランダムな画像が回転する
私のコードは次のとおりです。
Picasso.with(context)
.load(URLConstants.URL_BASE + imageURL)
.placeholder(image)
.error(image)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Matrix matrix = new Matrix();
try {
ExifInterface exif = new ExifInterface(URLConstants.URL_BASE + imageURL);
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
Log.d("EXIF", "Exif: " + orientation);
if (orientation == 6) {
matrix.setRotate(90);
} else if (orientation == 3) {
matrix.setRotate(180);
} else if (orientation == 8) {
matrix.setRotate(270);
}
} catch (Exception e) {
e.printStackTrace();
}
Bitmap oriented = Bitmap.createBitmap(bitmap, 0, 0,
bitmap.getWidth(), bitmap.getHeight(), matrix, true);
imageView.setImageBitmap(oriented);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
ExifInterface exif = new ExifInterface(URLConstants.URL_BASE + imageURL);
作品のURLを持つかどうかはわかりません。
もしそうでなければ、他にどんな方法がありますか?
をこのクラスを確認することができます。私はあなたが方向を適用せずにイメージを読み込もうとするべきだと思います。 –
どうすればいいですか? –
単純なアプローチ、Picasso.with(コンテキスト) .LOAD(URL) .placeholder(R.drawable.user_placeholder) .ERROR(R.drawable.user_placeholder_error) .into(ImageViewのを)試してみてください。 –