views:

58

answers:

3

I have an application that use the image captured by the mobile camera and sends it to a webservice. Currently I am putting the image in a byte[] which then will be transmitted. This is done by:

filename = cameracapturedialog.FileName;
FileStream fs = new FileStream(filename, FileMode.Open); 
byte[] ImageByte = new byte[fs.Length]; //file to send
fs.Read(ImageByte, 0, Convert.ToInt32(fs.Length));

But now I would like to perform some processing (resizing), hence I had to put the image into a BITMAP object, and after the processing I will convert it back to JPEG.

Is there a way to convert a JPEG into Bitmap and then back to JPEG without having no changes in the pixels (for testing I will perform no processing on the Bitmap)? Hence if I compare the first JPEG with the second JPEG I need that the files will be exactly the same.

What do you think the best solution is? Can I use something else instead of Bitmap. Any suggestion with some code will be greatly appreciated.

thanks

ReplyQuote

+1  A: 

http://stackoverflow.com/questions/41665/bmp-to-jpg-png-in-c

jgauffin
thanks but do not work on a mobile sdk :(
mouthpiec
A: 

No. You can save it with Quality=100 which would be almost like the original image. However, the resulting file will be huge.

danbystrom
+1  A: 

JPG is a lossy format. It will ALWAYS lose information because of the way the encoding algorithm works. So you'll never get the original image from a jpg, no matter what encoder you use.

Blindy