The easiest would be to store the dimensions to expect first, for example, this matrix:
1 1 1
2 2 2
3 3 3
Would be stored as
3 3 1 1 1 2 2 2 3 3 3
Where the first two threes would indicate that we're dealing with a 3x3 matrix. Then the data follow. Using an index, starting at 0 for the first one, then increasing you can find your matrix coordinate like this:
row = index/width; // Integer division, always rounds down
col = index%width; // Modulus
The final check would be to ensure that the index == width*height when you have reached the end of the file.
Also, when storing binary data using Qt, make sure to set your QDataStream version using myDataStreamObject->setVersion( xxx ); to ensure compatibility between Qt versions.





Reply With Quote
Bookmarks