当前位置: 代码迷 >> Windows Mobile >> 封存Image控件source 至本地出错
  详细解决方案

封存Image控件source 至本地出错

热度:1897   发布时间:2013-02-26 00:00:00.0
保存Image控件source 至本地出错
我在保存Image控件的图片时,老是出错,代码如下,请大家看看,谢谢

string message = "保存成功";
            try
            {
                BitmapSource source = ImagePanel.Source as BitmapSource;
                if (source == null)
                    return;
                WriteableBitmap wb = new WriteableBitmap(source);
              
                using (MemoryStream stream = new MemoryStream(50000))
                {
                    wb.SaveJpeg(stream, wb.PixelWidth, wb.PixelHeight, 0, 100);
                    stream.Seek(0, SeekOrigin.Begin);
                    Guid guid = Guid.NewGuid();
                    try
                    {
                        PhoneUtils.SavePicture(stream, guid.ToString() + ".jpg");
                    }
                    catch (Exception ex)
                    {
                        message = "保存失败,错误:" + ex.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

------解决方案--------------------------------------------------------
没搞过这方面,关注一下
  相关解决方案