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

概要

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

C# 画像を EPS に変換する

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

C# による BMP から EPS への変換

Aspose.Page による BMP から EPS への変換品質は、無料のオンライン ツール BMP から EPS へのコンバーター で確認でき、変換後の EPS ファイルは EPS ビューアー で確認できます。


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

手順:C# での BMP から EPS への変換 API コード

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

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

SaveImageToEps メソッドには、BMP イメージを EPS に保存するための最も快適な方法をユーザーに提供するための 4 つの変更点があります。

C# で文字列を使用して BMP を 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 BMP image to EPS file
10PsDocument.SaveImageAsEps(dataDir + "input1.bmp", dataDir + "output1.eps", options);

C# でストリームを使用して BMP を 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 BMP image to EPS file
7PsDocument.SaveImageAsEps(inputStream, outputStream, options);

C# で Bimap オブジェクトと文字列を使用して BMP を 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 bmp = new Bitmap(File.OpenRead(dataDir + "input1.bmp")))
10{
11	// Save BMP image to EPS file
12	PsDocument.SaveImageAsEps(bmp, 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 オブジェクトとストリームを使用して BMP を 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 bmp = new Bitmap(File.OpenRead(dataDir + "input1.bmp")))
10{
11	// Create the output stream fo EPS file
12	using(Stream outputStream = File.OpenWrite(dataDir + "output1.eps"))
13	{
14		// Save BMP image to EPS file
15		PsDocument.SaveImageAsEps(bmp, outputStream, options);
16	}
17}

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

BMP to EPS Converterで、BMPからEPSへのオンライン変換をお試しください。複数のBMP画像を一度にEPSファイルに変換し、数秒でダウンロードできます。

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

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.