Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8096257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:23:47+00:00 2026-06-05T21:23:47+00:00

I have this code: //choosed a picture public void onActivityResult(int requestCode, int resultCode, Intent

  • 0

I have this code:

//choosed a picture
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode == RESULT_OK) {
        if (requestCode == ImageHelper.SELECT_PICTURE) {

            String picture           = "";

            Uri selectedImageUri     = data.getData();
            //OI FILE Manager
            String filemanagerstring = selectedImageUri.getPath();
            //MEDIA GALLERY
            String selectedImagePath = ImageHelper.getPath(mycontext, selectedImageUri);

            picture=(selectedImagePath!=null)?selectedImagePath:filemanagerstring;

…

This is only a picture chooser, from gallery. This is nice, but when I open this picture on an ImageView, the images when took on “PORTRAIT MODE” with the camera look nice, but the images that took “LANDSCAPE MODE” with the camera, opening in -90 degrees.

How can i rotate those pictures back?

    Bitmap output       = Bitmap.createBitmap(newwidth, newheight, Config.ARGB_8888);
    Canvas canvas       = new Canvas(output);

I tried this:

Log.e("w h", bitmap.getWidth()+" "+bitmap.getHeight());
if (bitmap.getWidth()<bitmap.getHeight()) canvas.rotate(-90);

But this is not working, all image size is: *2560 1920 pixel (PORTRAIT, and LANDSCAPE mode all)

What can I do to rotate back the LANDSCAPE pictures?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:23:50+00:00Added an answer on June 5, 2026 at 9:23 pm

    If a photo is taken with a digital camera or smartphone, rotation is often stored in the photo’s Exif data, as part of the image file. You can read an image’s Exif meta-data using the Android ExifInterface.

    First, create the ExifInterface:

    ExifInterface exif = new ExifInterface(uri.getPath());
    

    Next, find the current rotation:

    int rotation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);  
    

    Convert exif rotation to degrees:

    int rotationInDegrees = exifToDegrees(rotation);
    

    where

    private static int exifToDegrees(int exifOrientation) {        
        if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) { return 90; } 
        else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {  return 180; } 
        else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {  return 270; }            
        return 0;    
     }
    

    Then use the image’s actual rotation as a reference point to rotate the image using a Matrix.

    Matrix matrix = new Matrix();
    if (rotation != 0) {matrix.preRotate(rotationInDegrees);}
    

    You create the new rotated image with the Bitmap.createBitmap method that take a Matrix as a parameter:

    Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height, Matrix m, boolean filter)
    

    where Matrix m holds the new rotation:

    Bitmap adjustedBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, width, height, matrix, true);
    

    See this tutorial for a useful source code example:

    • Read Exif information in a JPEG file.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I have this code that has one button that let's me choose an entry
i have this code right here: <select name=group> <option value=>Choose a group....</option> <?php foreach($groups
I have this JSP code snippet: <%@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c%> <c:choose> <c:when test=${var1.properties[\Item Type\]
I have this email sending code that does not show a chooser (good). How
I have a piece of code that look similar to this: <xsl:choose> <xsl:when test=some_test>
I have following code for alertdialog: AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this); helpBuilder.setTitle(Options); helpBuilder.setMessage(Choose Your
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2
In my app, I have write this code for capture video -(IBAction)takeVideo:(id)sender { [self

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.