【问题标题】:Android image from gallery intent来自画廊意图的 Android 图像
【发布时间】:2012-01-01 21:15:05
【问题描述】:

为什么当我有意从图库中加载图像时,它没有旋转。好像通过旋转的 Android Gallery 观看?

============================================

我是这样解决的

int orientation=getOrientationImageFile();

    Canvas c=new Canvas(bmO);

    if(orientation!=0){
        Matrix matrix=new Matrix();
        matrix.setRotate(orientation);
        c.drawBitmap(bm, matrix, new Paint());

        bm=Bitmap.createBitmap(bmO, 0, 0, bmO.getWidth(), bmO.getHeight(), matrix, true);
    }

private int getOrientationImageFile() {
        String[] proj = { MediaStore.Images.Media.ORIENTATION };
        Cursor cursor = managedQuery(selectedImageUri, proj, null, null, null);
        int column_index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.ORIENTATION);
        cursor.moveToFirst();
        return cursor.getInt(column_index);
}

selectedImageUri-这是从意图库返回的数据

bmO-由 selectedImageUri 创建的位图

我试了又试,它确实有效,但这是解决方案,还是可行的解决方案?还有其他更好的解决方案吗?

【问题讨论】:

  • 请详细说明您的问题。
  • @coder_For_Life22 比如我用手机在Gallery中横屏拍照,Android是显示不错的,但是如果我加载intent Gallery,这个就没有旋转了,还有很多图像上方和下方的黑色边框。无论是否设置了自动屏幕旋转,都会发生这种情况。

标签: android image image-gallery android-gallery


【解决方案1】:

因为 Android 画廊应用会为您做到这一点。所以,你需要自己实现这样的事情

别担心 - 这很简单:How to crop and rotate image programmatically in android?

【讨论】:

    猜你喜欢
    • 2012-10-03
    • 2015-08-30
    • 1970-01-01
    • 2015-05-25
    • 1970-01-01
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多