The following code reads a file 2 bytes at a time and stores the result in an array. It 's all right, but ... there is some other method of reading faster ?
Thanks in advance
Thanks in advance
B4X:
Dim raf As RandomAccessFile
Dim H As Int
Dim i As Int
Dim Buffer(1201*1201) As Int ' very big array
raf.Initialize2 (File.DirRootExternal , "DEM/3/N44E007.hgt", True, True) ' LittleEndian
Do While raf.CurrentPosition < raf.Size
B1=raf.ReadUnsignedByte(raf.CurrentPosition )
B2=raf.ReadUnsignedByte(raf.CurrentPosition )
H=B1*256+B2
Buffer(N)=H
Log ("B1=" & B1 & " B2=" & B2 & " H=" & H)
N=N+1
If N>10 Then Exit ' debug
Loop
'--- read the buffer
Log ("read the buffer")
For i=0 To 9
Log(Buffer(i))
Next
raf.Close