Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
Could you kindly help me? I want to convert a media file (image/audio/video) to an array of bytes and vice verse. I made the image converter but still the video and audio .. the idea of that is .. to send the media file as zeros and ones then reconvert it to original file.

Thanks in advance.
Posted
Updated 1-Apr-11 10:57am
v4

All files stored on a computer are binary. So I think that you might need to edit your question to make it clearer what it is that you want to do.
 
Share this answer
 
Comments
Hisham Ghatasheh 1-Apr-11 11:44am    
I'm sorry for that .. I mean zeros and ones
Thanks
Henry Minute 1-Apr-11 12:12pm    
That's what binary is - zeros and ones.

It is still not clear what you are trying to actually do.

Are you trying to write the binary values out to a file as text like "0001110101011010110"?

Or something else?
Sergey Alexandrovich Kryukov 1-Apr-11 12:16pm    
Henry, you're already demonstrated angelic patience.
I cannot even post my usual learning+RTFM set of instruction. At certain level of confusion, even learning won't help becuase can be misused to create futher confusions. Any ideas? :-)
--SA
Hisham Ghatasheh 1-Apr-11 16:49pm    
I'm now working on my own protocol the first step is to convert the media file to array of bytes and send it .. and the receiver should reconvert it from array of bytes to Audio/Video file..

I hope its clear now, and I'm so sorry for the weakness in my language !!!

Thank you
Henry Minute 1-Apr-11 16:57pm    
All you have to do is send the array of bytes. They're already binary. :)
Take a look at this:

MSDN Magazine[^]
 
Share this answer
 
v2
Comments
Hisham Ghatasheh 1-Apr-11 17:06pm    
Thank you ! .. I will try it ..
Dim sql As String = "INSERT INTO student VALUES(@Photo)"
Dim cmd As New SqlCommand(Sql, con)
Dim ms As New MemoryStream()
PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
Dim data As Byte() = ms.GetBuffer()
Dim p As New SqlParameter("@photo", SqlDbType.Image)
p.Value = data
cmd.Parameters.Add(p)
cmd.ExecuteNonQuery()
MessageBox.Show("record has been saved", "Save", MessageBoxButtons.OK)

i will searching too for the video converting to byte. but i have one of the solution you want to know. it only on the image file. you will set your data type to "image".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900