Hello, I have 64 rows, 16 cols of 1 byte LCD, I use 1024 bytes array to store a bitmap image. in this loop I want to read array element represents col byte(convert Row, Col to array index). any Ideas? For Row = 0 To 63 For Col = 0 To 15 Index = 'row and col something...
I am working with a native class that represents a 2D image as a 1D array. If you want to change one pixel, for example, you need to now how to derive the index from the x,y coordinates. So, let's...
or roll your own extra dimension, eg for a 12 x 16 array:
B4X:
Dim A(12 * 16) 'equivalent to Dim A(12, 16) ie both allocate 192 elements
A(5 * 16 + 8) = 42 'equivalent to A(5, 8) = 42
For I = 0 to 12 - 1
For J = 0 to 16 - 1
Log("A(" & I & ", " & J & ") = " & A(I * 16 + J)) 'equivalent to ... A(I, J)
Next
Next
edit: I saw "mapping function" and thought this meant B4X Map container and massive performance hit, but in retrospect "I * 16 + J" could also be called a mapping function and perhaps my performance nerve fired unnecessarily ?
I ended up doing it with a mapping function into a single dimension array.
Is there any particular reason why we can't have two or multiple dimensional arrays in B4R?