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 8397547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:49:07+00:00 2026-06-09T20:49:07+00:00

Just simple as the title, files opened with BitmapFactory.decodeFile have wrong orientation when it

  • 0

Just simple as the title, files opened with BitmapFactory.decodeFile have wrong orientation when it is displayed on the ImageView. The image its captured from the camera and saved on a tmp file so if the device has the bug that returns data.getData() null I have at least a reference to the file.

This just start the camera activity and capture the image file

private void startCamera() {
    Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    if (hasImageCaptureBug()) {
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Constants.TMPFILE_PATH)));
    } else {
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    startActivityForResult(intent, CAMERA_PIC_REQUEST);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_PIC_REQUEST) {
        if (resultCode == RESULT_OK) {
            Uri uri = null;

            if (hasImageCaptureBug()) {
                File f = new File(Constants.TMPFILE_PATH);
                try {
                    uri = Uri.parse(android.provider.MediaStore.Images.Media.insertImage(getContentResolver(), f.getAbsolutePath(), null, null));
                } catch (FileNotFoundException e) {

                }
            } else {
                uri = data.getData();
            }

            imageFilePath = Image.getPath(this, uri);

            if (Image.exists(imageFilePath)) {
                ImageView image = (ImageView) findViewById(R.id.thumbnail);
                int targetW     = (int) getResources().getDimension(R.dimen.thumbnail_screen_width);
                int degrees     = (int) Image.getRotation(this, uri);

                Bitmap bmp = Image.resize(imageFilePath, targetW);
                bmp = Image.rotate(bmp, degrees);

                image.setAdjustViewBounds(true);
                image.setImageBitmap(bmp);
            }
        }
    }
}

And this file resizes the image

public class Image {
    public static Bitmap resize(String pathName, int targetW) {
        BitmapFactory.Options opts = new BitmapFactory.Options();
        opts.inJustDecodeBounds = true;

        Bitmap bmp = BitmapFactory.decodeFile(pathName, opts);

        int photoW = opts.outWidth;
        int photoH = opts.outHeight;
        int targetH = Math.round((photoH * targetW) / photoW);
        int scaleFactor = Math.min(photoW/targetW, photoH/targetH);

        opts.inJustDecodeBounds = false;
        opts.inSampleSize = scaleFactor;
        opts.inPurgeable = true;

        bmp = BitmapFactory.decodeFile(pathName, opts);

        return bmp;
    }
}

Tryed to get the ExifOrientation but always its 0 because the file itself its correctly oriented just when I load it the file is displayed with the wrong orientation.

Regards

  • 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-09T20:49:09+00:00Added an answer on June 9, 2026 at 8:49 pm

    seems that my issue to preview the image was the Constants.TMPFILE_PATH, the image was not saved there, I just use this fix Display the latest picture taken in the image view layout in android!, but the issue persist if I post it to the server… I’ll check this as answered and open a new question to this…


    Edited

    To solve this issue just refactor the new image and then upload it to the server, because the raw data of the file itself has his exif orientation was wrong.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried django-filer to select mulitple files in a single filefield just i
We have a simple file browser on our intranet, built using ASP/vbscript. The files
I have created a simple flash menu and the SWF file, JS files (swfoject.js
I'm relatively new to coding; most of my work has been just simple GUI
Just a simple question, but can't get an answer on my own. In memory
Just a simple question: if I had a simple vector class: class Vector {
Just a simple question from a relative Java newbie: what is the difference between
Just a simple jquery tooltip when you rollover a div.
Just a simple but very often needed operation - how to prepend a string
Below just a simple race between 2 button in 2 threads, and this will

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.