简体   繁体   English

将图像从WP7发送到WCF并转换为位图

[英]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. 我正在尝试将图片从Windows Phone发送到WCF服务,该服务需要System.Drawing.Bitmap。 I however, am not able to take the BitmapImage from my phone, and get a Bitmap on the WCF service. 但是,我无法从手机上获取BitmapImage,也无法在WCF服务上获取位图。 I'm doing this in C#. 我在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. 我尝试过将BitmapImage转换为byte [],通过WCF发送,然后将其转换回BitmapImage,然后将其转换为Bitmap。 I can get the size of the BitmapImage, but the data in the image is empty. 我可以得到BitmapImage的大小,但是图像中的数据为空。 Any clues to what could go wrong? 关于可能出问题的任何线索?

How do I do this? 我该怎么做呢?

The problem probably is with the maxReceivedMessageSize . 问题可能出在maxReceivedMessageSize You said that you can get the size of the BitmapImage but is it the correct size? 您说可以获取BitmapImage的大小,但是正确的大小吗? If not then add the following line in your WCF's web.config: 如果没有,请在WCF的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. 现在再试一次,现在应该可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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