I am using a camera SDK from the manufacturer, and they are giving me a class called Image
with a pointer called data
of type byte*
that points to the beginning of the image data. They also give me a uint
called dataSize
that corresponds to the length of data
.
Now, I want to write this into a file using FileStream, but unfortunately the only write function in FileStream is of signature Write(Byte[], Int32, Int32)
. Naturally, if I try to use data
as a parameter to Write(...)
, it tells me I cannot convert from byte*
to byte[]
.
Since in my application, performance is critical, I want to avoid copying the data into a byte[]
array using Marshal.Copy(...)
as suggested in this answer.
What other options do I have available to me to take this byte*
pointer and write it to a file? Note that my overall goal is to take these images, which are coming in thousands per second, and write them to disk as fast as possible (i.e. sequentially for an SSD).