C++ का उपयोग करके EPS को TIFF में कैसे बदलें?

इस विषय में, हम यह पता लगाएंगे कि C++** का उपयोग करके **EPS को TIFF में कैसे बदलें। आप देखेंगे कि इनपुट ईपीएस फ़ाइल को कैसे लोड किया जाता है और इसे साधारण एपीआई कॉल का उपयोग करके सी ++ में छवि में परिवर्तित किया जाता है।

C++ का उपयोग करके EPS को TIFF में बदलने के चरण

  1. NuGet पैकेज मैनेजर टूल से Aspose.Page for C++ इंस्टॉल करें
  2. Aspose::Page नाम स्थान का संदर्भ जोड़ें
  3. आउटपुट ImageFormat निर्दिष्ट करें और इनपुट स्ट्रीम प्रारंभ करें
  4. PsDocument क्लास ऑब्जेक्ट का उपयोग करके इनपुट ईपीएस फ़ाइल लोड करें
  5. ImageSaveOptions गुण सेट करें और आउटपुट TIFF फ़ाइल सहेजें

आप कोड की कुछ पंक्तियों के साथ सरल API कॉल का उपयोग करके C++* का उपयोग करके TIFF को EPS निर्यात कर सकते हैं। आपको बस इनपुट ईपीएस फ़ाइल लोड करने और अपनी आवश्यकताओं के अनुसार अलग-अलग गुण सेट करने की आवश्यकता है, फिर फ़ाइल को C++ का उपयोग करके PsDocument class के साथ कनवर्ट करें।

C++ का उपयोग करके EPS को TIFF में बदलने के लिए कोड

#pragma once
#include <stdio.h>
#include <tchar.h>
#include <cstdint>
#include <Aspose.Page.Cpp/eps/src_eps/PsDocument.h>
#include <Aspose.Page.Cpp/eps/src_eps/PsConverterException.h>
#include <Aspose.Page.Cpp/eps/src_eps/Device/ImageSaveOptions.h>
#include <Aspose.Page.Cpp/eps/src_eps/Device/ImageDevice.h>
#include <Aspose.Page.Cpp/eps/src_eps/Device/PdfDevice.h>
#include <Aspose.Page.Cpp/eps/src_eps/Device/PdfSaveOptions.h>
#include <Aspose.Page.Cpp/License.h>
#include "system/enum.h"
#include "system/object.h"
#include "system/scope_guard.h"
#include "system/special_casts.h"
#include "system/type_info.h"
#include "system/details/dispose_guard.h"
#include "system/io/directory.h"
#include "system/io/directory_info.h"
#include "system/io/file.h"
#include "system/io/file_mode.h"
#include "system/io/memory_stream.h"
#include "system/io/stream.h"
#include "system/io/stream_reader.h"
#include "system/io/seekorigin.h"
#include "system/reflection/assembly.h"
#include "system/text/unicode_encoding.h"
#include "drawing/rectangle.h"
#include "drawing/bitmap.h"
#include "drawing/graphics.h"
#include <system/object.h>
#include <system/array.h>
#include <system/string.h>
#include <system/int32.h>
#include <system/shared_ptr.h>
#include <system/object_ext.h>
#include <system/exceptions.h>
#include <system/environment.h>
#include <system/diagnostics/trace.h>
#include <system/console.h>
using namespace Aspose::Page;
using namespace Aspose::Page::EPS;
using namespace Aspose::Page::EPS::Device;
using namespace System;
class EpsToTiffConverter {
public:
static void ConvertEPStoTIFF()
{
// Set the license for Aspose.Page for CPP to Convert EPS File
SharedPtr<License> EPStoTIFFlicense = System::MakeObject<License>();
EPStoTIFFlicense->SetLicense(u"Aspose.Total.NET.lic");
// Specify the output TIFF image format
System::SharedPtr<System::Drawing::Imaging::ImageFormat> imageFormat = System::Drawing::Imaging::ImageFormat::get_Tiff();
// Initialize PostScript input stream
System::SharedPtr<System::IO::FileStream> psStream = System::MakeObject<System::IO::FileStream>
(u"Input.eps", System::IO::FileMode::Open, System::IO::FileAccess::Read);
System::SharedPtr<PsDocument> document = System::MakeObject<PsDocument>(psStream);
// Set this flag if you want to convert EPS file ignoring minor errors
bool suppressErrors = true;
//Initialize ImageSaveOptions object with required parameters.
System::SharedPtr<ImageSaveOptions> options = System::MakeObject<ImageSaveOptions>(suppressErrors);
System::SharedPtr<ImageDevice> device = System::MakeObject<ImageDevice>(imageFormat);
{
auto __finally_guard_0 = ::System::MakeScopeGuard([&psStream]()
{
psStream->Close();
});
try
{
document->Save(device, options);
}
catch (...)
{
throw;
}
}
System::ArrayPtr<System::ArrayPtr<uint8_t>> imagesBytes = device->get_ImagesBytes();
int32_t i = 0;
{
for (System::ArrayPtr<uint8_t> imageBytes : imagesBytes)
{
System::String imagePath = System::IO::Path::GetFullPath(System::String(u"out_image") + System::Convert::ToString(i)
+ u"." + System::ObjectExt::ToString(imageFormat).ToLower());
{
System::SharedPtr<System::IO::FileStream> fs = System::MakeObject<System::IO::FileStream>(imagePath,
System::IO::FileMode::Create, System::IO::FileAccess::Write);
System::Details::DisposeGuard<1> __dispose_guard_1({ fs });
// ------------------------------------------
try
{
fs->Write(imageBytes, 0, imageBytes->get_Length());
}
catch (...)
{
__dispose_guard_1.SetCurrentException(std::current_exception());
}
}
i++;
}
}
}
};

पहले, हमने C++ का उपयोग करके Microsoft प्रोजेक्ट फ़ाइल मेटाडेटा कैसे निकालें को एक्सप्लोर किया था। हालाँकि, इस विषय में हमने लागू किया है कि कैसे C++ का उपयोग करके EPS से TIFF उत्पन्न करें।

 हिन्दी