GDI + / C#:如何保存图像作为EMF? [英] GDI+ / C#: How to save an image as EMF?

查看:798
本文介绍了GDI + / C#:如何保存图像作为EMF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您使用Image.Save方法将图像保存到一个EMF / WMF,你有一个exceptoin(<一个href=\"http://msdn.microsoft.com/en-us/library/ktx83wah.aspx\">http://msdn.microsoft.com/en-us/library/ktx83wah.aspx)

If you use Image.Save Method to save an image to a EMF/WMF, you got an exceptoin (http://msdn.microsoft.com/en-us/library/ktx83wah.aspx)

有另一种方式将图像保存到一个EMF / WMF?
是否有任何连接codeRS可用?

Is there another way to save the image to an EMF/WMF? Are there any encoders available?

谢谢
埃里克

推荐答案

图片是一个抽象类:你想要做什么取决于你是否正在处理一个图元文件位图

Image is an abstract class: what you want to do depends on whether you are dealing with a Metafile or a Bitmap.

创建与GDI +图像并保存为一个EMF与图元文件简单。每迈克的<一个href=\"http://stackoverflow.com/questions/152729/gdi-c-how-to-save-an-image-as-emf/152830#152830\">post:

Creating an image with GDI+ and saving it as an EMF is simple with Metafile. Per Mike's post:

var path = @"c:\foo.emf"
var g = CreateGraphics(); // get a graphics object from your form, or wherever
var img = new Metafile(path, g.GetHdc()); // file is created here
var ig = Graphics.FromImage(img);
// call drawing methods on ig, causing writes to the file
ig.Dispose(); img.Dispose(); g.ReleaseHdc(); g.Dispose();

这是你想要做的大部分时间,因为这是EMF是什么:保存矢量图像,GDI +绘图命令的形式

This is what you want to do most of the time, since that is what EMF is for: saving vector images in the form of GDI+ drawing commands.

您可以节省位图通过使用上述方法,并呼吁EMF文件 ig.DrawImage(your_bitmap),但要注意,这并不神奇隐蔽栅格数据到矢量图像。

You can save a Bitmap to an EMF file by using the above method and calling ig.DrawImage(your_bitmap), but be aware that this does not magically covert your raster data into a vector image.

这篇关于GDI + / C#:如何保存图像作为EMF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆