Android Question Get the bigger value from a list

Douglas Farias

Expert
Licensed User
Longtime User
hi all
i m using this code, to get the came previewsizes
B4X:
            Dim csz() As CameraSize
   
            csz = camEx.GetSupportedPreviewSizes
   
         For Each cs As CameraSize In csz
         Log("Cam Size: " & cs.Width & "x" & cs.Height )
         Next
here is the log
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:click.fight.valow
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (notifica) Create **
** Service (notifica) Start **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = false **
** Activity (telaprincipal) Create, isFirst = true **
** Activity (telaprincipal) Resume **
Cam Size: 960x720
Cam Size: 1280x720
Cam Size: 640x480
Cam Size: 352x288
Cam Size: 320x240
** Activity (main) Resume **

how can i get the bigger value? in this case 1280x720 ???
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
    Dim biggest As Int = 0
    For Each cs As CameraSize In csz
      If cs.Width > biggest Then
            biggest = cs.Width
        End If
        Log("Cam Size: " & cs.Width & "x" & cs.Height )
  Next
log(biggest)
???
 
Upvote 0

derez

Expert
Licensed User
Longtime User
I thoght of something like this:
B4X:
Dim csz() As CameraSize
csz = camEx.GetSupportedPreviewSizes
Dim Maxr As Int = 0
Dim mp As Map
mp.Initialize
For Each cs As CameraSize In csz
    mp.Put(cs.width, cs.height)
    Maxr = Max(Maxr, cs.width)
Next
Log("Largest = " & Maxr & " x " & mp.Get(Maxr))
But I haven't tried it.
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
B4X:
         Dim csz() As CameraSize
 
         csz = camEx.GetSupportedPreviewSizes
         Dim maxPreviewSize, maxPreviewIndex as Int
         maxPreviewSize = 0
         For i=0 to csz.size - 1
             Dim cs as CameraSize = csz.Get(i)
             If maxPreviewSize < cs.Width x cs.Height Then maxPreviewIndex = i
             Log("Cam Size: " & cs.Width & "x" & cs.Height)
         Next

         'Largest size
          cs = csz.Get(maxPreviewIndex)
          Log("Cam Size: " & cs.Width & "x" & cs.Height)

Wrote on my tablet as no PC to hand and so probably contains typo's but you hopefully get the idea.
 
Upvote 0
Top