简体   繁体   中英

Sending an Image from WP7 to WCF and converting to Bitmap

I'm trying to send a picture from my Windows Phone to a WCF service, which needs a System.Drawing.Bitmap. I however, am not able to take the BitmapImage from my phone, and get a Bitmap on the WCF service. I'm doing this in C#.

I've tried making the BitmapImage into a byte[], sending it over the WCF, and converting it back to a BitmapImage, and then converting that to a Bitmap. I can get the size of the BitmapImage, but the data in the image is empty. Any clues to what could go wrong?

How do I do this?

The problem probably is with the maxReceivedMessageSize . You said that you can get the size of the BitmapImage but is it the correct size? If not then add the following line in your WCF's web.config:

<bindings>
  <wsHttpBinding>
    <binding name="wsHttp"
                 maxReceivedMessageSize ="50000000"
                 messageEncoding="Mtom"
                 maxBufferPoolSize="50000000" >
      <readerQuotas maxDepth="32"
         maxStringContentLength="2147483647"
         maxArrayLength="2147483647"
         maxBytesPerRead="8192"
         maxNameTableCharCount="2147483647" />
    </binding>
  </wsHttpBinding>
</bindings>

Now try again, it should work now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM