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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:30:32+00:00 2026-05-29T10:30:32+00:00

In my app i am using this code to get Image from Gallery and

  • 0

In my app i am using this code to get Image from Gallery and Camera:

@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) {     
    super.onActivityResult(requestCode, resultCode, data);     
    if (requestCode == 10 && resultCode == Activity.RESULT_OK) {             
        Uri contentUri = data.getData();          
        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();         
        imagePath = cursor.getString(column_index);           
        //Bitmap croppedImage = BitmapFactory.decodeFile(imagePath);
        tempBitmap = BitmapFactory.decodeFile(imagePath);
        if(!(tempBitmap == null))
        {
            // here i am changing display to the tempBitmap
            photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true);
            //photoBitmap = Bitmap.createBitmap(tempBitmap, 0, 0, tempBitmap.getWidth(), tempBitmap.getHeight());
            takePhotoFromGallery = true;// edited
        }
        else
            Toast.makeText(getApplicationContext(), "Image is not valid", Toast.LENGTH_SHORT).show();

    } 
    if(resultCode == RESULT_OK && requestCode==TAKE_PHOTO_CODE){
         final File file = getTempFile(this);         
         try {           
             tempBitmap = Media.getBitmap(getContentResolver(), Uri.fromFile(file));
             photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true);
             takePhotoFromCamera = true;
             // do whatever you want with the bitmap (Resize, Rename, Add To Gallery, etc)         
        } catch (FileNotFoundException e) {           
            e.printStackTrace();         
        } catch (IOException e) {           
            e.printStackTrace();         
        } 
    }
}

Now, all works fine. But i got Image as Stratch.

I thaught it is because this line:

photoBitmap = Bitmap.createScaledBitmap(tempBitmap, display.getWidth(), display.getHeight(), true);

here i am stratching the image width,height with display’s width,height.

I want is the Image should be Dispaly as we can normaly show thew image in gallery. So how to make it possible ???

This is the image which i am snaping from the Camera:

enter image description here

And Now this is What i see in my Application:

enter image description here

Now Second image got little stratch. as because of that line code.

So what should i have to do to make is normal in its height and width ??
Thanks.
Thanks.

  • 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-05-29T10:30:34+00:00Added an answer on May 29, 2026 at 10:30 am

    Use ImageView and set scale type of image view to Center-Inside.

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

Sidebar

Related Questions

This is using the web app framework, not Django. The following template code is
I am currently using the following code to get an UIImage from an ALAsset
EDIT - I was able to fix this problem using code from 'Farray' with
I'm using this django app to implement PayPal IPN. I'm testing it using PayPal's
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a
I am using this middleware to make my app restful, but it looks like
Using this answer , I created a sample localized app. My question is, is
This link describes an exploit into my app using fckEditor: http://knitinr.blogspot.com/2008/07/script-exploit-via-fckeditor.html How do I
I am using C# and a console app and I am using this script

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.