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

Android Question barcode & QR recognition in portrait mode

Discussion in 'Android Questions' started by leitor79, Aug 28, 2019.

  1. leitor79

    leitor79 Active Member Licensed User

    Hi,

    I've using this example and, after the last update that fixed the red rectangle position, I can't manage to use in portrait mode.

    Before, I've done this:
    Code:
    If 100%x < 100%y Then
                       r.Initialize(
    100%x - br.GetField("y"),tl.GetField("x") , 100%x - tl.GetField("y"),  br.GetField("x"))
                       
    Log(r)
                   
    Else
                       
    'landscape
                       r.Initialize(tl.GetField("x"), tl.GetField("y"), br.GetField("x"), br.GetField("y"))
                   
    End If
    But now, since (I think) there are scales involved, the "100%x -... " doesn't work.

    I've tried the following:

    - Uncommenting TR and BL points, since them would be the "new" TL and BR when the phone is (un)rotated.

    - Use them for initialization: r.initialize(bl.getfield("x"), bl.getfield("y"), tr.getfield("x"), tr.getfield("y"))

    - Scaling according the rotation:
    Code:
    If 100%x < 100%y Then
                        
                        r.Left = r.Left * yscale
                        r.Right = r.Right * yscale
                        r.Top = r.Top * xscale
                        r.Bottom = r.Bottom * xscale
                    
    Else
                        
    'landscape
                        
                        r.Left = r.Left * xscale
                        r.Right = r.Right * xscale
                        r.Top = r.Top * yscale
                        r.Bottom = r.Bottom * yscale
                    
    End If
    Any help is appreciated!
    Thank you!
     
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