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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:23:55+00:00 2026-06-18T03:23:55+00:00

Photo is rotating 90 degree while capturing from camera in samsung mobile rest of

  • 0

Photo is rotating 90 degree while capturing from camera in samsung mobile rest of other mobiles(HTC) its working fine. Please help me for this.

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, IMAGE_CAPTURE); 

@Override 
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {     
    super.onActivityResult(requestCode, resultCode, data);    
      try
    {
    if (requestCode == IMAGE_CAPTURE) {
       if (resultCode == RESULT_OK){

       Uri contentUri = data.getData();
       if(contentUri!=null)
       {
        String[] proj = { MediaStore.Images.Media.DATA };         
            Cursor cursor = managedQuery(contentUri, proj, null, null, null);         
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);         
        cursor.moveToFirst();         
        imageUri = Uri.parse(cursor.getString(column_index));
       }

       tempBitmap = (Bitmap) data.getExtras().get("data"); 
       mainImageView.setImageBitmap(tempBitmap);
       isCaptureFromCamera = true;
    }
 }
  • 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-18T03:23:57+00:00Added an answer on June 18, 2026 at 3:23 am

    Some device rotate image according to device orientation .

    here i have write one common method to get orientation and get image in right scale

        public  Bitmap decodeFile(String path) {//you can provide file path here 
            int orientation;
            try {
                if (path == null) {
                    return null;
                }
                // decode image size 
                BitmapFactory.Options o = new BitmapFactory.Options();
                o.inJustDecodeBounds = true;
                // Find the correct scale value. It should be the power of 2.
                final int REQUIRED_SIZE = 70;
                int width_tmp = o.outWidth, height_tmp = o.outHeight;
                int scale = 0;
                while (true) {
                    if (width_tmp / 2 < REQUIRED_SIZE
                            || height_tmp / 2 < REQUIRED_SIZE)
                        break;
                    width_tmp /= 2;
                    height_tmp /= 2;
                scale++;
                }
                // decode with inSampleSize
                BitmapFactory.Options o2 = new BitmapFactory.Options();
                o2.inSampleSize = scale;
                Bitmap bm = BitmapFactory.decodeFile(path, o2);
                Bitmap bitmap = bm;
    
                ExifInterface exif = new ExifInterface(path);
    
                orientation = exif
                        .getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
    
                Log.e("ExifInteface .........", "rotation ="+orientation);
    
    //          exif.setAttribute(ExifInterface.ORIENTATION_ROTATE_90, 90);
    
                Log.e("orientation", "" + orientation);
                Matrix m = new Matrix();
    
                if ((orientation == ExifInterface.ORIENTATION_ROTATE_180)) {
                    m.postRotate(180);
    //              m.postScale((float) bm.getWidth(), (float) bm.getHeight());
                    // if(m.preRotate(90)){
                    Log.e("in orientation", "" + orientation);
                    bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),
                            bm.getHeight(), m, true);
                    return bitmap;
                } else if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
                    m.postRotate(90); 
                    Log.e("in orientation", "" + orientation);
                    bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),
                            bm.getHeight(), m, true);
                    return bitmap;
                }
                else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
                    m.postRotate(270);
                    Log.e("in orientation", "" + orientation);
                    bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(),
                            bm.getHeight(), m, true);
                    return bitmap;
                } 
                return bitmap;
            } catch (Exception e) {
                return null;
            }
    
        }
    

    EDIT:

    This code is not optimized , i just show the logic code from my one of the test project.

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

Sidebar

Related Questions

tl;dr: User interface layout is broken when rotating the iPad while taking a photo,
if ([dict objectForKey:@photo] !=(id)[NSNull null]) {NSLOG(@dictinary is not empty)} This is not working for
Some iOS photo-related apps store images created with the app somewhere other than the
Facebook recently added photo-tagging capabilities to its Graph API: http://developers.facebook.com/blog/post/509/ I am using FbConnect
I'am opening camera app on click of a button. And displaying the captured photo
Photo of my problem: First (from left to right) is Google chrome. Second is
Photo capture Intent causes NullPointerException on Samsung phones only. Implementation below. final Button capture
In photo app of iphone you can see smooth scrolling to the other picture
I'm displaying a photo with a small scrollable TextView below it. On HTC Wildfire
I have a JS photo gallery that loads individual images from an API into

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.