繁体   English   中英

来自图库意图的Android图片

[英]Android image from gallery intent

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

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

我这样解决了

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创建的位图

我试了又试,都可以,但是是解决方案,还是可以解决的方案? 还有其他更好的解决方案吗?

因为Android Gallery应用程序可以帮您实现。 所以,你需要自己实现

不用担心-这很简单: 如何在Android中以编程方式裁剪和旋转图像?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM