怎么样将byte[]里的emf格式的图片读取到matefile中 
Pbyte 为从数据库中读取的emf文件的数据 
如下: 
Graphics gs = this.CreateGraphics();            
MemoryStream ms = new MemoryStream(); 
ms.Read(Pbyte, 0, Pbyte.Length); 
IntPtr hdc = new IntPtr(); 
hdc = gs.GetHdc(); 
Metafile mf = new Metafile(new MemoryStream(), hdc); 
并未有那张图片请高手们指点该怎么样取到matefile中 
急急急 

解决方案 »

  1.   

       protected void FillImage()
          {
            SqlConnection conn = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
            conn.Open();        SqlCommand cmd = new SqlCommand("select top 1 picture from T_Picture order by id desc", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            dr.Read();        MemoryStream ms = new MemoryStream((Byte[])dr["picture"]);
            Bitmap image = new Bitmap(ms);
            image.Save(Server.MapPath("~/1.jpg"));        this.Image1.ImageUrl = "1.jpg";        dr.Close();
            conn.Close();
          }
      

  2.   

    我要的不是这个我要保存的是emf图元图片也就是矢量图片你这个弄出来的图片是失真的
      

  3.   

    自己解决如下
    Graphics gs = this.CreateGraphics();            
    MemoryStream ms = new MemoryStream(Pbyte); 
    IntPtr hdc = new IntPtr(); 
    hdc = gs.GetHdc(); 
    Metafile mf = new Metafile(ms, hdc); 
      

  4.   

         Graphics gs = this.CreateGraphics();
                MemoryStream ms = new MemoryStream();
                ms.Write(Pbyte, 0, Pbyte.Length);            IntPtr hdc = new IntPtr();
                hdc = gs.GetHdc();
                Metafile mf = new Metafile(new MemoryStream(), hdc); 你代码有点问题把 你的MemoryStream 本身是new 出来了 你再去读一次ms.Read 不是没影响?  改成Write看看。
      

  5.   

    Graphics gs = this.CreateGraphics();            
    MemoryStream ms = new MemoryStream(Pbyte); 
    IntPtr hdc = new IntPtr(); 
    hdc = gs.GetHdc(); 
    Metafile mf = new Metafile(ms, hdc); 
    这样也不行!解决不了不好意思!有没有高手啊!出来解决一下
      

  6.   

     Bitmap bmp = new Bitmap(220,220);
        Graphics gs = Graphics.FromImage(bmp);
    MemoryStream ms = new MemoryStream(Pbyte);
        Metafile mf  = new Metafile(ms,gs.GetHdc());