簡體   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