G
Guest
Hi All -
I've got a 3rd party COM object that returns an array of bytes that are a
TIFF image. After adding the reference to the com object to my solution the
C# signature
for the method is something like this:
System.Array Item.GetContent();
I need to save the bytes to a file that will be the tiff file...so when I
see System.Array I think "serialization". I have code like:
System.Array theBytes = anItem.GetContent();
FileStream fs = new FileStream("image.tif", FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, theBytes);
fs.Close();
Problem is, the serialize function adds more stuff to the file than just the
raw data and its no longer a valid TIFF!
The only way I could get it to work was to loop through the array and write
1 byte
at a time but performance is terrible! (And performance *is* an issue!)
Is ther a way to write the contents of System.Array as binary data quickly?
Or optionally, how do I convert System.Array to a byte[] (without looping
through all the data)?
Please help! I'm really stuck!
I've got a 3rd party COM object that returns an array of bytes that are a
TIFF image. After adding the reference to the com object to my solution the
C# signature
for the method is something like this:
System.Array Item.GetContent();
I need to save the bytes to a file that will be the tiff file...so when I
see System.Array I think "serialization". I have code like:
System.Array theBytes = anItem.GetContent();
FileStream fs = new FileStream("image.tif", FileMode.Create);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, theBytes);
fs.Close();
Problem is, the serialize function adds more stuff to the file than just the
raw data and its no longer a valid TIFF!
The only way I could get it to work was to loop through the array and write
1 byte
at a time but performance is terrible! (And performance *is* an issue!)
Is ther a way to write the contents of System.Array as binary data quickly?
Or optionally, how do I convert System.Array to a byte[] (without looping
through all the data)?
Please help! I'm really stuck!