我正在编写一个 android 应用程序,并为用户提供从库中加载图片的能力。
图片已加载但旋转了 90 度。有时它会旋转 -90 度。当您通过库查看图片时,如何“以相同的方式”加载图片?因此,如果它旋转了,那么一定要加载它旋转它。但如果是正确的,那么它应该以同样的方式加载
非常感谢你
对不起,我应该添加我的代码,这里是:
try {
Intent choosePictureIntent = new Intent(Intent.ACTION_PICK, Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(choosePictureIntent, REQUEST_CHOOSE_IMAGE);
} catch (Exception e) {
e.printStackTrace();
}
break;
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case REQUEST_CHOOSE_IMAGE:
if(resultCode == RESULT_OK){
Uri selectedImage = imageReturnedIntent.getData();
InputStream imageStream;
try {
imageStream = getContentResolver().openInputStream(selectedImage);
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream, null, options );
ivPictureChosen.setImageBitmap(yourSelectedImage); //ivPictureChosen is image view to display the picture
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(this, "Couldn't pick image", Toast.LENGTH_SHORT).show();
}
}
}
}