将Silverlight WriteableBitmap转换为ASP.Net Bitmap [英] Convert Silverlight WriteableBitmap to ASP.Net Bitmap

查看:112
本文介绍了将Silverlight WriteableBitmap转换为ASP.Net Bitmap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我的应用程序使用网络摄像头拍摄快照并将其保存在本地文件夹中。所以我使用以下代码转换我的Silverlight图像并通过Web服务发送它。我的网络服务的名称是ImageService。



hi friends, my application take snapshots using webcam and save them in a local folder. so i''m using following code to convert my Silverlight Image and send it through the Web Service. name of my web service is ImageService.

ImageServiceSoapClient client = new ImageServiceSoapClient();

private void source_CaptureImageCompleted(object sender, CaptureImageCompletedEventArgs e)
        {            
            WriteableBitmap bmp = new WriteableBitmap(320, 240);
            bmp = e.Result;
            byte[] buffer = bmp.ToByteArray();            
                     
            client.SaveImageToLocalAsync(buffer, txtUserName.Text);            
        }







这是我的服务器端代码..






and this is my server side code..

[WebMethod]
 public string SaveImageToLocal(byte[] buffer,string name)
 {

     try
     {
         Bitmap bmp = new Bitmap(320, 240);
         using (MemoryStream stream = new MemoryStream(buffer))
         {
             bmp = new Bitmap(stream);
             string saveString = GetFolder() + name + ".jpg";
             bmp.Save(saveString, System.Drawing.Imaging.ImageFormat.Jpeg);
         }

         return "Servers says : Saved..!!";
     }
     catch (Exception ex)
     {
         return "Server says : " + ex.Message;
     }
 }







所以当我运行这个应用程序,我得到一个例外说服务器说:参数无效 ..



有谁能告诉我什么这段代码错了吗?我花了几周时间来解决这个问题。请支持我!! !!谢谢..




so when i run this application, i''m getting an exception saying "Server says : Parameter is not valid"..

can anyone please tell me what''s wrong with this code? i spent weeks to solve this problem. please back me up..!! thanks..

推荐答案

请看我对这个问题的评论。



没有这样的事情ASP.NET位图。您甚至可以在ASP.NET中使用WPF位图,为什么不呢? ASP.NET是一种服务器端技术,因此,没有.NET UI,因此您可以使用任何图形库。






对于转换,请参阅此代码示例:

http://snipplr.com/view/63090/ [ ^ ]。



-SA
Please see my comment to the question.

There is no such thing as ASP.NET bitmap. You can use WPF bitmaps even in ASP.NET, why not? ASP.NET is a server-side technology, so, there is no .NET UI, and therefore you can use any graphics library.



For the conversion, see, for example, this code sample:
http://snipplr.com/view/63090/[^].

—SA


这篇关于将Silverlight WriteableBitmap转换为ASP.Net Bitmap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆