Convert BMP to EPS using API for C++
Overview
This article explains how to convert BMP to EPS using C++. It covers the following topics.
- C++ Image to EPS
- C++ BMP to EPS
- C++ Convert BMP to EPS
- C++ How to Convert BMP to EPS Programmatically
- C++ Save BMP as EPS
Converting image to EPS using C++ from other formats like JPG, TIFF, PNG etc is similar to BMP.
C++ BMP to EPS Conversion
You can check the quality of Aspose.Page BMP to EPS conversion and view the results via free online BMP to EPS Converter and then view the resulting EPS file with our EPS Viewer
Steps: BMP to EPS Converter API Code in C++
It is necessary to do just 2 steps in order to perform BMP to EPS conversion:
- Create an instance of PsSaveOptions.
- Use static method SaveImageToEps of PsDocument.
SaveImageToEps method has four modifications to provide a user with the most comfortable way to save BMP image to EPS.
Using strings for saving BMP to EPS in C++
In the following C++ code snippet the input image and the output EPS file are assigned by strings:
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);
Using streams for saving BMP to EPS in C++
In the following C++ code snippet input image and output EPS file are assigned by streams:
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);
Using Bimap object and string for saving BMP to EPS in C++
In the following C++ code snippet input image is assigned by Bitmap object and the output EPS file is assigned by string:
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 }
For Linux, MacOS and other non-Windows operation systems we offer to use our Aspose.Page.Drawing Nuget package. It uses Aspose.Drawing backend instead of System.Drawing system library. So import Aspose.Page.Drawing namespace instead of System.Drawing one. In the above and the following code snippets Aspose.Page.Drawing.Bitmap will be used instead of System.Drawing.Bitmap. Our code examples on GitHub contain all the necessary substitutions.
Using Bimap object and stream for saving BMP to EPS in C++
In the following C++ code snippet input image is assigned by Bitmap object and the output EPS file is assigned by stream:
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 }
Evaluate BMP to EPS conversion online on our BMP to EPS Converter. You can convert several BMP image to EPS files at once and dowload results in a few seconds.
You can download examples and data files from
GitHub.