Skip to content

Camera2 image rotation on certain devices #1

@Andrec-Dxs

Description

@Andrec-Dxs

I created a camera project based on your project. I found that you created a variable to check whether if the width of the bitmap generated for the photo is greater than the height, but you don't use the result for anything.

I came upon an issue related with my device always rotating the photo compared to other devices where the image was on the right orientation. Consider using the following code to fix this issue.

var widthGreaterThanHeight = bitmap.Width > bitmap.Height;

            Matrix matrix = new Matrix();

            if (widthGreaterThanHeight)
                matrix.PostRotate(90);
            else
                matrix.PostRotate(0);

            bitmap = Bitmap.CreateBitmap(bitmap, 0, 0, bitmap.Width, bitmap.Height, matrix, true);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions