Android Question barcode & QR recognition in portrait mode

leitor79

Active Member
Licensed User
Longtime 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:
B4X:
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:
B4X:
                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!
 
Top