使用 .NET API 将 BMP 转换为 EPS
概述
本文讲解如何使用 C# 将 BMP 转换为 EPS。内容涵盖以下主题:
本文涵盖了如何使用 C# 将 JPG、TIFF、PNG 等其他格式的图像转换为 EPS。
C# BMP 转 EPS
您可以通过免费在线 <a nofollow 工具检查 Aspose.Page BMP 转 EPS 的质量并查看结果href=“ https://products.aspose.app/page/conversion/bmp-to-eps">BMP 到 EPS 转换器,然后使用我们的 EPS 查看器 查看生成的 EPS 文件
步骤:BMP 转 EPS 转换器 API 代码(C# 编写)
只需执行以下两个步骤即可完成 BMP 转 EPS 转换:
- 创建 PsSaveOptions 实例。
- 使用 PsDocument 的静态方法 SaveImageToEps。
SaveImageToEps 方法有四处修改,以便用户以最便捷的方式将 BMP 图像保存为 EPS 文件。
在 C# 中使用字符串将 BMP 图像保存为 EPS 文件
在以下 C# 代码片段中,输入图像和输出 EPS 文件均通过字符串赋值:
1// Convert BMP image to EPS using files paths.
2
3// Create default options
4PsSaveOptions options = new PsSaveOptions();
5
6// Save BMP image to EPS file
7PsDocument.SaveImageAsEps(DataDir + "input.bmp", OutputDir + "output_bmp.eps", options);在 C# 中使用流将 BMP 图像保存为 EPS 图像
以下 C# 代码片段通过流指定输入图像和输出 EPS 文件:
1// Convert BMP image to EPS using streams.
2
3// Create default options
4PsSaveOptions options = new PsSaveOptions();
5
6// Create input stream from image
7using (FileStream input = new FileStream(DataDir + "input.bmp", FileMode.Open))
8{
9 // Create output stream for EPS
10 using (FileStream output = new FileStream(OutputDir + "output_bmp.eps", FileMode.Open))
11 {
12 // Save BMP image from input file stream to EPS file output stream
13 PsDocument.SaveImageAsEps(input, output, options);
14 }
15}在 C# 中使用 Bimap 对象和字符串将 BMP 图像保存为 EPS 文件
以下 C# 代码片段中,输入图像由 Bitmap 对象赋值,输出 EPS 文件由字符串赋值:
1// Convert BMP image to EPS from Bitmap object to file.
2
3// Create default options
4PsSaveOptions options = new PsSaveOptions();
5
6using (Bitmap bmp = new Bitmap(DataDir + "input.bmp"))
7{
8 // Save BMP bitmap to EPS file
9 PsDocument.SaveImageAsEps(bmp, OutputDir + "output_bmp.eps", options);
10}对于 Linux、MacOS 和其他非 Windows 操作系统,我们建议使用我们的 Aspose.Page.Drawing Nuget 包。它使用 Aspose.Drawing 后端,而不是 System.Drawing 系统库。
因此,请导入 Aspose.Page.Drawing 命名空间,而不是 System.Drawing 命名空间。在上面和下面的代码片段中,将使用 Aspose.Page.Drawing.Bitmap 代替 System.Drawing.Bitmap。我们在 GitHub 上的代码示例包含所有必要的替换。
在 C# 中使用 Bimap 对象和流将 BMP 保存为 EPS
在以下 C# 代码片段中,输入图像由 Bitmap 对象分配,输出 EPS 文件由流分配:
1// Convert BMP image to EPS from Bitmap object to stream.
2
3// Create default options
4PsSaveOptions options = new PsSaveOptions();
5
6using (Bitmap bmp = new Bitmap(DataDir + "input.bmp"))
7{
8 // Create output stream for EPS
9 using (FileStream output = new FileStream(OutputDir + "output_bmp.eps", FileMode.Open))
10 {
11 // Save BMP bitmap to EPS file stream
12 PsDocument.SaveImageAsEps(bmp, output, options);
13 }
14}使用我们的 BMP 到 EPS 转换器 在线评估 BMP 到 EPS 的转换效果。您可以一次将多个 BMP 图像转换为 EPS 文件,并在几秒钟内下载结果。
您可以从 GitHub 下载示例和数据文件。