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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:38:13+00:00 2026-06-07T04:38:13+00:00

I am working on an Android app that uses the phone’s camera and I’m

  • 0

I am working on an Android app that uses the phone’s camera and I’m using a custom code.

The problem is that the image is showing in the preview is not correct (the image aspect ratio is not OK).

If I use the following code:

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {

   Camera.Parameters params = mCamera.getParameters();
   List<Camera.Size> sizes = params.getSupportedPreviewSizes();
   Camera.Size selected = sizes.get(0);
   params.setPreviewSize(selected.width,selected.height);
   mCamera.setParameters(params);
   mCamera.startPreview();

the preview image is OK (I think little part of the image top and bottom is not showed).

The problem then is that the captured image showed after takePicture method is called is not showed correctly (the image aspect ratio is not OK, the image appears to be compressed into the view), even so if I save the picture to a file image appears to be OK.

I wonder if it is possible to show the image correctly in both cases. Suggestions?

  • 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-07T04:38:15+00:00Added an answer on June 7, 2026 at 4:38 am

    The solution was easy, but I didn’t know I must set correct aspect ratio MANUALLY (it is not an automatic process, I supposed it was and this step it is not explained in most how to’s). Finally, I solved it this way:

    1. Getting supported sizes using params.getSupportedPreviewSizes() and params.getSuppertedPictureSize().

    2. Computing the best aspect ratio (width/height) according to the measures width and height passed in surfaceChanged(SurfaceHolder holder, int format, int width, int height).

    3. Setting the best preview size and picture size using setPreviewSizeand setPictureSize, respectively, before startPreview() method is called.

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

Sidebar

Related Questions

I'm working on an Android app that shows a camera preview. Ideally I'd like
I am working on an Android app that uses the gdata-java-client to download documents
I am working on an android app that uses google maps. now I would
I'm working on an Android app that uses Geopoints and I want to determinate
I'm working on an Android app that uses high-resolution GPS data. It's designed to
I'm working on an Android app, specifically one that uses the Facebook Android SDK.
Ok, I am working on an Android app that uses a service to collect
I'm using eclipse to develop an android app that also uses the ndk. I
I'm working on an app that, among other things, uses the device's camera to
I'm working on an Android app using the Windows Live services which uses OAuth2

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.