怎么样将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中
急急急
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中
急急急
{
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();
}
Graphics gs = this.CreateGraphics();
MemoryStream ms = new MemoryStream(Pbyte);
IntPtr hdc = new IntPtr();
hdc = gs.GetHdc();
Metafile mf = new Metafile(ms, hdc);
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看看。
MemoryStream ms = new MemoryStream(Pbyte);
IntPtr hdc = new IntPtr();
hdc = gs.GetHdc();
Metafile mf = new Metafile(ms, hdc);
这样也不行!解决不了不好意思!有没有高手啊!出来解决一下
Graphics gs = Graphics.FromImage(bmp);
MemoryStream ms = new MemoryStream(Pbyte);
Metafile mf = new Metafile(ms,gs.GetHdc());