爲什麼圖像在imageView中旋轉90度?以及如何解決它?爲什麼圖像在ImageView中旋轉90度?
圖庫中的所有圖像都不會在imageView中旋轉90度。
我不知道爲什麼一些圖像在imageView中旋轉了90度。
@Override
protected void onActivityResult(int requestCode , int resultCode , Intent data){
if(requestCode == 100){
if(resultCode == Activity.RESULT_OK){
try{
ImageView imageView = (ImageView)View.inflate(this, R.layout.imagelayout, null);
Uri imgUri = data.getData();
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imgUri);
int height = bitmap.getHeight();
int width = bitmap.getWidth();
int newHeight = height;
int newWidth = width;
float rate = 0.0f;
if(width > height){
if(imageFlipper.getWidth() < width){
rate = imageFlipper.getWidth()/(float) width ;
newHeight = (int) (height * rate);
newWidth = imageFlipper.getWidth();
}
}else{
if(imageFlipper.getHeight() < height){
rate = imageFlipper.getHeight()/(float) height ;
newWidth = (int) (width * rate);
newHeight = imageFlipper.getHeight();
}
}
Bitmap reSize = Bitmap.createScaledBitmap(bitmap , newWidth , newHeight,true);
imageView.setImageBitmap(reSize);
//imageView.setImageURI(imgUri);
imageFlipper.addView(imageView);
imageFlipper.setDisplayedChild(imageFlipper.getChildCount() - 1);
}catch(Exception e){
e.printStackTrace();
}
}
}
}
即使沒有imageFlipper,這會發生嗎? –
哦,我會嘗試'~~ – tokhi