Hi guys,
How do i go about converting images files like jpeg's in to bytes?
Im doing the work in c#, the .net 2.0 platform, if that makes any difference...
really need some help on this, thanks!
Bobski
Printable View
Hi guys,
How do i go about converting images files like jpeg's in to bytes?
Im doing the work in c#, the .net 2.0 platform, if that makes any difference...
really need some help on this, thanks!
Bobski
in asp.net 1.1 i use HttpPostedFile and use the "InputStream.Read" method of it .
something like this
then uploadData has all the bytes in an array, and you can flush it or write it to a new file.Code:HttpPostedFile theFile = this.myFile.PostedFile;
byte[] uploadData = new Byte[nFileLen]; //nFileLen is the size of the file in bytes
theFile.InputStream.Read(uploadData,0,nFileLen);
//the above line reads the posted file into a byte array called uploadData.
hth,
mcm
Appreciate the response, but i dont think it helps tho,
any other suggestions pls
Is the file on your computer? You could try the following:Quote:
Originally Posted by Bobski
Code:foreach(Byte b in File.ReadAllBytes(@"c:\test\sunset.jpg"))
Console.Write("{0} ", b.ToString("X2"));
Code:byte[] bytes = null;
using( MemoryStream ms = new MemoryStream() ) {
myBmp.Save(ms, ... );
ms.Seek(0,0);
bytes = ms.ToArray();
}
// bytes contains the image
***********************
Is the file on your computer? You could try the following:
Code:
foreach(Byte b in File.ReadAllBytes(@"c:\test\sunset.jpg"))
Console.Write("{0} ", b.ToString("X2"));
*************************
Yeh mate this seems to work, thx.
Im basically trying to change it into bytes so i can send it over a bluetooth connection using OBEX to a mobile device. All i need to know now is how to convert this back to an image so i can display it on the phone. Oh how i love programming ;-)
Thanks