문제

I tried several things to try to get the camera preview to show up in portrait on a SurfaceView. Nothing worked. I am testing on a Droid that has 2.0.1. I tried:

1) forcing the layout to be portrait by: this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

2) using

Camera.Parameters parameters = camera.getParameters();
parameters.set("orientation", "portrait");
parameters.setRotation(90);
camera.setParameters(parameters);

Is there something else I can try? If this a bug in Android or the phone how can I make sure that this is the case so that I have proof to inform the client?

Thanks, Prasanna

올바른 솔루션이 없습니다

다른 팁

People Picker는 Active Directory와 사용자 프로필 서비스 모두에 연결됩니다.사용자 프로필 서비스 이름이없는 경우에도 AD에서 해결됩니다.

페이지 레이아웃은 페이지에 컨트롤을 추가합니다.페이지 자체는 동적으로 구성되므로 SharePoint Designer에서는 편집 할 수 없습니다.

브라우저에서 페이지를 편집하고 콘텐츠 편집기 웹 파트를 페이지 본문에 추가 할 수 있습니다.그런 다음 해당 CEWP를 JavaScript, CSS 또는 HTML로 파일로 연결할 수 있습니다.이것은 사용자 정의 요소를 페이지 레이아웃으로 정의한 페이지에 주입하는 일반적인 해결 방법입니다.

CEWP의 HTML을 편집하려고하지 마십시오.대부분의 SharePoint는 절약시이를 제거합니다.파일에 사용자 지정 HTML / CSS / JavaScript를 만듭니다.해당 파일을 문서 라이브러리에 업로드 한 다음 페이지의 CEWP를 해당 파일로 연결하십시오.

You can try this (good for 2.2 or below). Here I rotate the image before saving it to sd card. But it is only for portrait mode. If you had to make it for both mode then you should check camera orientation and put some check before capturing image.

PictureCallback jpegCallback = new PictureCallback() {
   public void onPictureTaken(byte[] data, Camera camera) {
      FileOutputStream outStream = null;
      try {
        imageFilePath = getFilename();
        InputStream is = new ByteArrayInputStream(data);
        Bitmap bmp = BitmapFactory.decodeStream(is);
        // Getting width & height of the given image.
        if (bmp != null){
           int w = bmp.getWidth();
           int h = bmp.getHeight();
           // Setting post rotate to 90
           Matrix mtx = new Matrix();
           mtx.postRotate(90);
           // Rotating Bitmap
           Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
           ByteArrayOutputStream stream = new ByteArrayOutputStream();
           rotatedBMP.compress(Bitmap.CompressFormat.PNG, 100, stream);
           byte[] byteArray = stream.toByteArray(); 
           outStream = new FileOutputStream
                              (String.format(imageFilePath,System.currentTimeMillis()));
           outStream.write(byteArray);
           outStream.close();
        } else {
           outStream = new FileOutputStream
                              (String.format(imageFilePath,System.currentTimeMillis()));
           outStream.write(data);
           outStream.close();           
        }       

        preview.camera.startPreview();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
    }
  }
};

There's no way to do this on many current devices, including the G1 and Droid. Take a look at the relevant bug report here:

Also see a comment from one of the Android engineers (Dave) here:

The link Roman gave of the issue thread has a workable solution that I'm using now.

Find it here: http://code.google.com/p/android/issues/detail?id=1193#c26

There is no need you have to set any parameters for the orientation until you need to do that explicitly. By Default, it supports this facility. In my case, i have a Activity and above that activity i have a camera view, so i didn't set any orientation for the camera properties, instead for the activity i set the orientation as portrait in the Manifest file. now the app looks and works good. Might be helpful for some one..

Thanks.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top