用silverlight开发了一个涂鸦板,现在可以将涂鸦板生成一个.png的图片.因为要将图片传到服务器上去,所以需要指定图片名字.请问如何在不打开系统对话框的情况下,设置.png文件的名字,然后上传到服务器!!!坐等

解决方案 »

  1.   

     WriteableBitmap _bitmap = new WriteableBitmap(iPresenter, null);
                //生成预览
                // this.showIP.Source = _bitmap;
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "PNG Files (*.png)|*.png|All Files (*.*)|*.*";
                sfd.DefaultExt = ".png";
                sfd.FilterIndex = 1;
                //sfd.SafeFileName = "";
                if ((bool)sfd.ShowDialog())
                {                using (Stream fs = sfd.OpenFile())
                    {
                        IsolatedStorageFile store =
                        IsolatedStorageFile.GetUserStoreForApplication();
                        int width = _bitmap.PixelWidth;
                        int height = _bitmap.PixelHeight;
                        EditableImage ei = new EditableImage(width, height);
                        for (int i = 0; i < height; i++)
                        {
                            for (int j = 0; j < width; j++)
                            {
                                int pixel = _bitmap.Pixels[(i * width) + j];
                                ei.SetPixel(j, i,
                                            (byte)((pixel >> 16) & 0xFF),
                                            (byte)((pixel >> 8) & 0xFF),
                                            (byte)(pixel & 0xFF),
                                            (byte)((pixel >> 24) & 0xFF)
                                );
                            }
                        }
                        //获取流
                        Stream png = ei.GetStream();
                        int len = (int)png.Length;
                        byte[] bytes = new byte[len];
                        png.Read(bytes, 0, len);
                        fs.Write(bytes, 0, len);
                        
                        string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                        //string FileName = Environment;
                        MessageBox.Show("图片保存成功!");
                    }
    }
    这里是网上可以找到的保存代码!!!
      

  2.   

    http://www.silverlightchina.net/html/tips/2011/0727/9314.html
    http://tech.ddvip.com/2008-11/122688969492844_2.html
      

  3.   

    SOS..SOS..SOS..SOS..SOS..SOS..