I try to save a matrix of rgb pixel in file with C# and read it in python.
If my image is 243*507, then the len of the file must be (height * width * rgb) then 243*507*3 (I save each rgb value as a byte in file).
When I read this file with C#, it have the good len (369603), it work perfectly.
But with python, I get 369570 or with another file, a bit more or a bit less. It always missing bytes in the python string when I read the file.
For get the image file, download frame.txt
Code in python:
f = open(path, "r")
if f.mode != 'r':
print_cerror("Can't read file")
contents = f.read()
f.close()
print(len(contents) # Not the good len
Code in C#:
if (File.Exists(file_path))
{
string text = System.IO.File.ReadAllText(file_path);
Debug.Log("READ LEN = " + text.Length); // Perfect 369603 !
}
EDIT: When I tried to use "rb" the size of the file is 477537 instead of 369603. I think that it have a header or other informations. How can I get only the body of the file ? I tried with seek(0, 1, 2) but it only skip 0, 1, 2 first bytes...
OK PROBLEM SOLVED:
My bad, I wrote bytes as text with C# then the file wasn't good x) Sorry