55import android .graphics .Bitmap ;
66import android .support .v7 .app .AppCompatActivity ;
77import android .os .Bundle ;
8+ import android .util .Log ;
89import android .widget .ImageView ;
910
1011import com .clock .study .R ;
@@ -33,13 +34,17 @@ protected void onCreate(Bundle savedInstanceState) {
3334 super .onCreate (savedInstanceState );
3435 setContentView (R .layout .activity_photo_preview );
3536
36- mPhotoPreview = (ImageView ) findViewById (R .id .iv_photo_preview );
37+ mPhotoPreview = (ImageView ) findViewById (R .id .iv_preview_photo );
3738
3839 mImageFile = (File ) getIntent ().getSerializableExtra (EXTRA_IMAGE );
3940 int requestWidth = (int ) (RuleUtils .getScreenWidth (this ) * RATIO );
4041 int requestHeight = (int ) (RuleUtils .getScreenHeight (this ) * RATIO );
4142 Bitmap bitmap = BitmapUtils .decodeBitmapFromFile (mImageFile , requestWidth , requestHeight );//按照屏幕宽高的3/4比例进行缩放显示
4243 if (bitmap != null ) {
44+ int degree = BitmapUtils .getBitmapDegree (mImageFile .getAbsolutePath ());//检查是否有被旋转,并进行纠正
45+ if (degree != 0 ) {
46+ bitmap = BitmapUtils .rotateBitmapByDegree (bitmap , degree );
47+ }
4348 mPhotoPreview .setImageBitmap (bitmap );
4449 }
4550 }
@@ -49,4 +54,5 @@ public static void preview(Activity activity, File file) {
4954 previewIntent .putExtra (EXTRA_IMAGE , file );
5055 activity .startActivity (previewIntent );
5156 }
57+
5258}
0 commit comments