title: Saving an image via web service
body: <p>Alright, long story short. I'm developing software similar to the devices UPS delivery divers use. We have to ways to get a proof of delivery(POD). The first is a signature and the second is a picture taken by the camera.</p>
  
  <p>Now the device that is capturing these images sends them to a web service we have which then goes and saves them on the server. The device saves these two as different file types, png for the signature and jpg for the picture,  but the web service saves them as jpg files. Currently the signatures are working but the pictures keep throwing an exception "generic exception occurred gdi+".</p>
  
  <p>I don't understand why one will save just fine but the other keeps throwing the error message. Especially since they both use the same code when they are on the server side. </p>
  
  <p>I've gone searched throw the stack overflow and haven't found anything that solves my issue and I've googled to no avail. Anyone have any suggestions on what to do to get the pictures to save?</p>
  
  <p>Device logic to turn the image into a string so it can be sent to the web service. </p>
  
  <pre><code>**Picture from camera logic**
  Using MS As New System.IO.MemoryStream(), BM As New Bitmap(ImagePath)
       BM.Save(MS, System.Drawing.Imaging.ImageFormat.Jpeg)
       ImageString = Convert.ToBase64String(MS.ToArray())
  End Using
  
  **Signature logic**
  Using MS As New System.IO.MemoryStream(), BM As New Bitmap(ImagePath)
       BM.Save(MS, System.Drawing.Imaging.ImageFormat.png)
       ImageString = Convert.ToBase64String(MS.ToArray())
  End Using
  </code></pre>
  
  <p>Web Service logic to turn image back into string, then save it as jpeg.</p>
  
  <pre><code>Dim Image As Drawing.Bitmap = Nothing
  Dim ByteImage As Byte()
  
  If ImageString.IsNullOrEmpty = False Then
      ByteImage = Convert.FromBase64String(ImageString)
  
      Using stream As New MemoryStream(ByteImage, 0, ByteImage.Length)    
           stream.Write(ByteImage, 0, ByteImage.Length)
           Image = CType(Drawing.Bitmap.FromStream(stream, True), Drawing.Bitmap)
      End Using
      Image.Save(FileLocation,Drawing.Imaging.ImageFormat.Jpeg)
  End If
  </code></pre>
  
  <p>That Image.Save is what is throwing the exception.</p>