1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question CameraExClass weird problem

Discussion in 'Android Questions' started by Alberto Michelis, Jul 5, 2019.

  1. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    Hi, I dont know if I will explain it very well
    Compiling the example of CameraExClass, when I see the phone screen, the aspect ratio of the image is no ok, in portrait mode the image is taller than the reality and in landscape its wider but, when I save the picture is ok.

    Im using the code suggested in :https://www.b4x.com/android/forum/threads/cameraex-stretching-preview.62462/

    This code changes the Panel1 layout ok, but what you see inside panel1 is still the same, in portrait taller and in lanscape wider.
     
    Last edited: Jul 5, 2019
  2. Peter Simpson

    Peter Simpson Expert Licensed User

    Hello @Alberto Michelis,
    In CameraEx you can set the resolution that you require. For example a photo ratios are usually 4x3, so what I do is I loop through all the resolutions that the camera/phone can use until I reach one that has a ration of 4x3, for example 800x600 is 4x3, but I select a higher resolution that is 4x3. Once you find the resolution that you want to use, you can set CameraEx to use that resolution, for example 1600x1200 etc etc etc.

    Your screen preview might still look a bit off (which you can also set if need be), but the photo will look perfect.
     
  3. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    Problem is not the resolution, may be Im not explaining ok. Problem is, with the same resolution, in portrait mode you se the camera image taller and changing to landscape mode you see it wider.
     
  4. Peter Simpson

    Peter Simpson Expert Licensed User

    Okay I've got you, I've not got my laptop on me at the moment but if my memory servers me correctly, what I do is rotate the bitmap, something like this before saving re-saving the image.

    Code:
    If ChkBoxSaveRotated.Checked Then BmpPhoto = BmpPhoto .Rotate(270Else BmpPhoto = BmpPhoto .Rotate(0)
    Enjoy...
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    The default example doesn't set the panel size based on the preview ratio, so the image is expected to be stretched. You need to change the panel size before the camera is initialized.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice