Thank you Erel,
I don't use B4J because what I am working on is an old Lazarus-Pascal based project using many other components and it would need huge work to transfer it to B4J. I am now trying to extend this project with support for cameras that's why I also try to find a solution using B4A for the mobile part.
The images are small JPEGs, not more than 100KB. The check I do with FFD9 may not be very reliable but since I cannot use prefix mode, I cannot find any other way.
I have searched the B4A forums for days but also did not find something that could help.
JPEGs (on the PC side) are generated by my code (they are screenshots received from a camera) and having checked thousands of them, I found that all of them have that FFD9 in the end of the file, so I estimate that it may be OK.
Saving the data to a file is not efficient either because I would need to do repeat it fast enough (about 4-5 times per second or even more). I think it would cause problems.
But anyway, how could I save the new data (binary) from a list to a file ?
This code works if I have a buffer (array), but when having a list what could I use ?
Generally, since an array of bytes can be moved to a list for better handling (like extending), why there is no easy way to do the opposite, meaning transfer a list having elements of bytes to an array (buffer) ?
Dim out As OutputStream
counter2 = counter2 + 1
out = File.OpenOutput(File.DirRootExternal, "scr_" & counter2 & ".jpg", False)
out.WriteBytes(input_buffer, 0, input_buffer.Length)
out.Close
Finally, before using list, I tried using ArrayCopy but had other problems there : Before calling ArrayCopy had to Dim the total_buffer (that would hold the final image) with the size of the current total_buffer + buffer, but beause of the "Dim" the total_buffer was initialized and lost all previous bufferings.
Any help on these subjects would be greatly appreaciated !