How to convert bytearray to bitstream?Pls help.
Hi
I’m not fully sure I understand your question…
Do you want to convert the byte array to a string representation of bits? Or do you want to put the bytes into a stream that can be serialized or sent across a network? Or do you want to have a bunch of bits of variable length in pattern (not grouped in 8’s)?
This may help if you are wanting to have variable length bit patterns: A BitStream Class for the .NET Framework - CodeProject
Please elaborate and somebody may be able to help further.
Ta
JT
I have a jpg file which i have encoded to PNG format using EncodeToPNG().I want to put the bytes into a stream that can be serialized or sent across a network.
The solution is to use System.IO.BinaryWriter to write to your stream. (You should be able to pass the byte array directly to the System.IO.BinaryWriter.Write(byte[ ]) method after creating an instance of BinaryWriter pointing to the Stream object you want to write to.)
MSDN has an example on how to read and write binary data to a file here: Reading and Writing to a Newly Created Data File.
Replace FileStream with a stream class of your choice in case you don’t want to write the data to a file.