RxGalleryFinal icon indicating copy to clipboard operation
RxGalleryFinal copied to clipboard

竖屏拍的图片在图片浏览页面中旋转了90°

Open yuruizhe opened this issue 7 years ago • 4 comments

如题,手机三星盖世4, 4.4.2

yuruizhe avatar May 31 '17 06:05 yuruizhe

三星手机是会有旋转90度的问题。

sheep0704 avatar May 31 '17 06:05 sheep0704

各个厂商的图片加载库好像可以自动翻转的吧。如果不好使是不是可以如下:

// 图片旋转角度
        int rotate = 0;

        ExifInterface exif = new ExifInterface(imagePath);

        // 先获取当前图像的方向,判断是否需要旋转
        int imageOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);


        switch (imageOrientation)
        {
            case ExifInterface.ORIENTATION_ROTATE_90:
                rotate = 90;
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                rotate = 180;
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                rotate = 270;
                break;
            default:
                break;
        }


        // 获取当前图片的宽和高
        int w = bitmap.getWidth();
        int h = bitmap.getHeight();

        // 使用Matrix对图片进行处理
        Matrix mtx = new Matrix();
        mtx.preRotate(rotate);

//        // 旋转图片
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, false);
        bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);

yuruizhe avatar May 31 '17 07:05 yuruizhe

使用了只是手机端展示问题,三星手机你旋转过去的话,电脑打开来依然是不对的。

sheep0704 avatar Jun 22 '17 02:06 sheep0704

Picasso 的旋转好像是多余的,旋转后的角度反而是错的

epolar avatar Aug 22 '17 03:08 epolar