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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:02:32+00:00 2026-05-27T16:02:32+00:00

With the following code shows a preview of the camera vertically and it’s works..

  • 0

With the following code shows a preview of the camera vertically and it’s works..
BUT!! I get a photo in landscape! 🙁

How I can build it vertically?
I’ve the preview view in vertical, but I can’t save the picture vertically.

greetings and thanks,
Fran

ONCLICK

public void onClick(View arg0) {
       camera.takePicture(myShutterCallback, myPictureCallback_RAW, myPictureCallback_JPG);
}

PREVIEW

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
        int height) {
    if (previewing) {
        camera.stopPreview();
        previewing = false;
    }
    if (camera != null) {
        /*
         * camera.setPreviewDisplay(surfaceHolder); camera.startPreview();
         * previewing = true;
         */
        Camera.Parameters parameters = camera.getParameters();
        parameters.setPreviewSize(width, height);
        camera.setParameters(parameters);

        // Condicions per utilitzar la orientacio adecuada segons el sdk
        if (Integer.parseInt(Build.VERSION.SDK) >= 8)
            setDisplayOrientation(camera, 90);
        else {
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
                parameters.set("orientation", "portrait");
                parameters.set("rotation", 90);
            }
            if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
                parameters.set("orientation", "landscape");
                parameters.set("rotation", 90);
            }
            camera.setParameters(parameters);
        }

        // camera.startPreview();
        previewing = true;
    }
}

TAKE PHOTO

PictureCallback myPictureCallback_JPG = new PictureCallback() {
    @Override
    public void onPictureTaken(byte[] arg0, Camera arg1) {
        // intentar canvia horientacio
        Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);
        //bitmapPicture.

        OutputStream imageFileOS;
        try {
            imageFileOS = new FileOutputStream(String.format("/sdcard/DCIM/iboo/captura.jpg"));
            imageFileOS.write(arg0);
            imageFileOS.flush();
            imageFileOS.close();
            // Missatge en cas de capturar l'imatge correctament
            Toast.makeText(Principal.this, "Imatge Capturada!",
                    Toast.LENGTH_LONG).show();
            MostrarFoto("/sdcard/DCIM/iboo/captura.jpg");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        // camera.startPreview();


                }
};
  • 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-27T16:02:33+00:00Added an answer on May 27, 2026 at 4:02 pm

    It is the solution I implemented. It works perfectly. I hope that helps.

    PictureCallback myPictureCallback_JPG = new PictureCallback() {
        @Override
        public void onPictureTaken(byte[] arg0, Camera arg1) {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 6;
            options.inDither = false; // Disable Dithering mode
            options.inPurgeable = true; // Tell to gc that whether it needs free
                                        // memory, the Bitmap can be cleared
            options.inInputShareable = true; // Which kind of reference will be
                                                // used to recover the Bitmap
                                                // data after being clear, when
                                                // it will be used in the future
            options.inTempStorage = new byte[32 * 1024];
            options.inPreferredConfig = Bitmap.Config.RGB_565;
            bMap = BitmapFactory.decodeByteArray(arg0, 0, arg0.length, options);
    
            // others devices
            if(bMap.getHeight() < bMap.getWidth()){
                orientation = 90;
            } else {
                orientation = 0;
            }
    
            Bitmap bMapRotate;
            if (orientation != 0) {
                Matrix matrix = new Matrix();
                matrix.postRotate(orientation);
                bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(),
                        bMap.getHeight(), matrix, true);
            } else
                bMapRotate = Bitmap.createScaledBitmap(bMap, bMap.getWidth(),
                        bMap.getHeight(), true);
    
    
            FileOutputStream out;
            try {
                out = new FileOutputStream(
                        String.format("/sdcard/DCIM/test/screen.jpg"));
                bMapRotate.compress(Bitmap.CompressFormat.JPEG, 90, out);
                if (bMapRotate != null) {
                    bMapRotate.recycle();
                    bMapRotate = null;
                }
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            camera.startPreview();
            MostrarFoto(imageInSD);
            editor = prefs.edit();
            editor.putString("PathSeleccio", imageInSD);
            editor.commit();
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code shows that I can insert uncompatible type into Map, but when
In the following code, the first log statement shows a decimal as expected, but
I am trying to use jquery dialog, but the following code shows 0, 1
The following code shows how you can have text truncated by a div with
The following code shows a button that allows you to select a file (should
I have the following code that shows either a bug or a misunderstanding on
Consider the following code which shows compile time error : #include <stdio.h> int main(int
The following piece of code shows an Insert table dialog: Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
The following code shows what I would like to do; that is, I would
the following code shows invalid qualifier when executed Dim strs As String Dim insStr

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.