.NET API を使用して PNG を EPS に変換

概要

この記事では、C# を使用して PNG を EPS に変換する方法 について説明します。以下のトピックを取り上げます。

C# 画像から EPS へ

これらの記事では、C# を使用して BMP、TIFF、JPG などの他の形式から EPS へ画像に変換する方法について説明します。

C# PNG から EPS への変換

Aspose.Page の PNG から EPS への変換品質を確認し、無料のオンラインツールで結果を確認できます。 PNG から EPS へのコンバーター を使用し、生成された EPS ファイルを EPS ビューアー で表示します。


Aspose.Page for .NET の PNG から EPS へのコンバーターを使用すると、.NET プラットフォームでサポートされている任意の言語(C#、VB、J#)を使用して、PNG 画像を Encapsulated PostScript (EPS) ファイルに変換できます。

手順:C# での PNG から EPS へのコンバーター API コード

PNG から EPS への変換は、以下の 2 つの手順で実行できます。

  1. PsSaveOptions のインスタンスを作成します。
  2. PsDocument の静的メソッド SaveImageToEps を使用します。

SaveImageToEps メソッドには、PNG 画像を EPS に保存するための最も簡単な方法を提供するために、4 つの変更が加えられています。

C# で文字列を使用して PNG 画像を EPS に保存する

次の C# コード スニペットでは、入力画像と出力 EPS ファイルが文字列によって割り当てられています。

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2
 3// The path to the documents directory.
 4string dataDir = GetDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8
 9// Save PNG image to EPS file
10PsDocument.SaveImageAsEps(dataDir + "input1.png", dataDir + "output1.eps", options);

C# でストリームを使用して PNG を EPS に保存する

次の C# コードスニペットでは、入力画像と出力 EPS ファイルがストリームによって割り当てられています。

1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
2
3// Create default options
4PsSaveOptions options = new PsSaveOptions();
5
6// Save PNG image to EPS file
7PsDocument.SaveImageAsEps(inputStream, outputStream, options);

C# で Bimap オブジェクトと文字列を使用して PNG を EPS に保存する

次の C# コードスニペットでは、入力画像に Bitmap オブジェクトが割り当てられ、出力 EPS ファイルに文字列が割り当てられています。

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2
 3// The path to the documents directory.
 4string dataDir = GetDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8// Create the bitmap object from image file
 9using(Bitmap png = new Bitmap(File.OpenRead(dataDir + "input1.png")))
10{
11	// Save PNG image to EPS file
12	PsDocument.SaveImageAsEps(png, dataDir + "output1.eps", options);
13}

Linux、macOS、その他のWindows以外のオペレーティングシステムでは、 Aspose.Page.Drawing NuGetパッケージをご利用いただけます。このパッケージは、System.Drawingシステムライブラリではなく、Aspose.Drawingバックエンドを使用します。

そのため、System.Drawing名前空間ではなく、Aspose.Page.Drawing名前空間をインポートしてください。上記および以下のコードスニペットでは、System.Drawing.Bitmapではなく、Aspose.Page.Drawing.Bitmapが使用されます。GitHubのコード例には、必要な置換がすべて含まれています。

C# で Bimap オブジェクトとストリームを使用して PNG を EPS に保存する

次の C# コードスニペットでは、入力画像が Bitmap オブジェクトに割り当てられ、出力 EPS ファイルがストリームに割り当てられています。

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2
 3// The path to the documents directory.
 4string dataDir = GetDataDir();
 5
 6// Create default options
 7PsSaveOptions options = new PsSaveOptions();
 8// Create the bitmap object from image file
 9using(Bitmap png = new Bitmap(File.OpenRead(dataDir + "input1.png")))
10{
11	// Create the output stream fo EPS file
12	using(Stream outputStream = File.OpenWrite(dataDir + "output1.eps"))
13	{
14		// Save PNG image to EPS file
15		PsDocument.SaveImageAsEps(png, outputStream, options);
16	}
17}

PNGからEPSへの変換については、 JavaC++をご覧ください。

PNG to EPS ConverterでPNGからEPSへの変換をオンラインで評価できます。複数のPNG画像を一度にEPSファイルに変換し、数秒で結果をダウンロードできます。

サンプルファイルとデータファイルは GitHubからダウンロードできます。

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.