C++用APIを使用してBMPをEPSに変換する

概要

この記事では、C++ を使用して BMP を EPS に変換する方法 について説明します。以下のトピックをカバーしています。

C++ で画像を EPS に変換する

JPG、TIFF、PNG などの他の形式から C++ を使用して画像を EPS に変換する方法は、BMP の場合と似ています。

C++ BMPからEPSへの変換

Aspose.Page による BMP から EPS への変換品質を確認し、無料のオンライン BMP to EPS Converter で結果を確認できます。その後、EPS Viewer で変換後の EPS ファイルを表示できます。

Steps: BMP to EPS Converter API Code in C++

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-C
 2
 3    // The path to the documents directory.
 4    System::String dataDir = RunExamples::GetDataDir_WorkingWithImageConversion();
 5    
 6    // Create default options
 7    System::SharedPtr<PsSaveOptions> options = System::MakeObject<PsSaveOptions>();
 8    
 9    // Save JPEG image to EPS file
10    PsDocument::SaveImageAsEps(dataDir + u"input1.bmp", dataDir + u"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-C
2
3    // Create default options
4    System::SharedPtr<PsSaveOptions> options = System::MakeObject<PsSaveOptions>();
5    
6    // Save JPEG image to EPS file
7    PsDocument::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-C
 2
 3    // The path to the documents directory.
 4    System::String dataDir = RunExamples::GetDataDir_WorkingWithImageConversion();
 5    
 6    // Create default options
 7    System::SharedPtr<PsSaveOptions> options = System::MakeObject<PsSaveOptions>();
 8    
 9    System::SharedPtr<System::Drawing::Bitmap> bmp = System::MakeObject<System::Drawing::Bitmap>(System::IO::File::OpenRead(dataDir + u"input1.bmp"));
10    // Clearing resources under 'using' statement
11    System::Details::DisposeGuard<1> __dispose_guard_0({ bmp});
12    // ------------------------------------------
13
14    try
15    {
16        PsDocument::SaveImageAsEps(bmp, dataDir + u"output1.eps", options);
17    }

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-C
 2
 3    // The path to the documents directory.
 4    System::String dataDir = RunExamples::GetDataDir_WorkingWithImageConversion();
 5    
 6    // Create default options
 7    System::SharedPtr<PsSaveOptions> options = System::MakeObject<PsSaveOptions>();
 8    
 9    System::SharedPtr<System::Drawing::Bitmap> bmp = System::MakeObject<System::Drawing::Bitmap>(System::IO::File::OpenRead(dataDir + u"input1.bmp"));
10    // Clearing resources under 'using' statement
11    System::Details::DisposeGuard<1> __dispose_guard_0({ bmp});
12    // ------------------------------------------
13
14    try
15    {
16        System::SharedPtr<System::IO::Stream> outputStream = System::IO::File::OpenWrite(dataDir + u"output1.eps");
17        // Clearing resources under 'using' statement
18        System::Details::DisposeGuard<1> __dispose_guard_0({ outputStream});
19        // ------------------------------------------
20        try
21        {
22            PsDocument::SaveImageAsEps(bmp, outputStream, options);
23        }
24    }

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.