1

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.

bkaid
  • 51,465
  • 22
  • 112
  • 128
mouthpiec
  • 3,923
  • 18
  • 54
  • 73

2 Answers2

1

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
  • 65,249
  • 10
  • 91
  • 131
0

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

Dan Byström
  • 9,067
  • 5
  • 38
  • 68