怎么样将byte[]里的emf格式的图片读取到matefile中

wangjintao 2009-05-28 09:24:12
怎么样将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中
急急急
...全文
131 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
sobug 2012-04-19
  • 打赏
  • 举报
回复
Bitmap bmp = new Bitmap(220,220);
Graphics gs = Graphics.FromImage(bmp);
MemoryStream ms = new MemoryStream(Pbyte);
Metafile mf = new Metafile(ms,gs.GetHdc());
wangjintao 2009-06-02
  • 打赏
  • 举报
回复
有没有高手解决一下啊???
wangjintao 2009-05-29
  • 打赏
  • 举报
回复
Graphics gs = this.CreateGraphics();
MemoryStream ms = new MemoryStream(Pbyte);
IntPtr hdc = new IntPtr();
hdc = gs.GetHdc();
Metafile mf = new Metafile(ms, hdc);
这样也不行!解决不了不好意思!有没有高手啊!出来解决一下
wangjintao 2009-05-29
  • 打赏
  • 举报
回复
错了!好像还是不行!
zgke 2009-05-29
  • 打赏
  • 举报
回复
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看看。
wangjintao 2009-05-29
  • 打赏
  • 举报
回复
自己解决如下
Graphics gs = this.CreateGraphics();
MemoryStream ms = new MemoryStream(Pbyte);
IntPtr hdc = new IntPtr();
hdc = gs.GetHdc();
Metafile mf = new Metafile(ms, hdc);
wangjintao 2009-05-29
  • 打赏
  • 举报
回复
有没有高手解决一下啊?
andrewbornglobal 2009-05-28
  • 打赏
  • 举报
回复
唉,比较烦
wuyq11 2009-05-28
  • 打赏
  • 举报
回复
修改一下昵称 2009-05-28
  • 打赏
  • 举报
回复
路过帮顶...ing
wangjintao 2009-05-28
  • 打赏
  • 举报
回复
不一样的!因为这个图我要打印的!图片小了点!矢量图的话放大打钱出来就不会失真的你这种图片格式打钱出来的图片会模糊我主要是为了解决这个问题
polaris737784883 2009-05-28
  • 打赏
  • 举报
回复
是二进制转图片对吧
对吧
如果是
思路应该差不多的
这个是我以前写的一个东西
呵呵
wangjintao 2009-05-28
  • 打赏
  • 举报
回复
我要的不是这个我要保存的是emf图元图片也就是矢量图片你这个弄出来的图片是失真的
polaris737784883 2009-05-28
  • 打赏
  • 举报
回复
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();
}

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧