@ ahsaniqbalsidiqui,
-
I was trying to save barcode png into ‘Memory Stream’, but compiler is giving an error.
-
barcodeGenerator->get_Parameters()->get_Barcode()->get_Padding()->get_Top()->set_Millimeters(2.f); ==> these settings also giving compilation error
I am giving the sample below:
#include
#include <system/aspose_cpp_library.h>
#include <system/exception.h>
#include <system/io/path.h>
#include <Licensing/License.h>
#include
#include <system/string.h>
#include <system/shared_ptr.h>
#include <system/object.h>
#include <system/environment.h>
#include <system/console.h>
#include <Generation/EncodeTypes/SymbologyEncodeType.h>
#include <Generation/EncodeTypes/EncodeTypes.h>
#include <Generation/BarCodeImageFormat.h>
#include <BarCode.Generation/BarcodeGenerator.h>
#include <BarCode.Generation/GenerationParameters/BaseGenerationParameters.h>
#include <BarCode.Generation/GenerationParameters/BarcodeParameters.h>
#include <BarCode.Generation/Helpers/Unit.h>
#include <BarCode.Generation/GenerationParameters/CodetextParameters.h>
#include <Generation/CodaBarSymbol.h>
#include <BarCodeRecognition/Recognition/RecognitionSession/BarCodeReader.h>
#include <BarCodeRecognition/Recognition/RecognitionSession/DecodeTypes/DecodeType.h>
#include <system/io/memory_stream.h>
void GenerateCode128()
{
std::cout << “GenerateCode128(): Started\n”;
//--------------------------------------------------------------------------------------//
const System::String codeText = u"ABCTZCS1234567890T4444T5678901234XYZ";
System::SharedPtr<Aspose::BarCode::Generation::BarcodeGenerator> barcodeGenerator = System::MakeObject<Aspose::BarCode::Generation::BarcodeGenerator>(Aspose::BarCode::Generation::EncodeTypes::Code128, codeText);
barcodeGenerator->get_Parameters()->get_Barcode()->get_CodeTextParameters()->set_Location(Aspose::BarCode::Generation::CodeLocation::None);
barcodeGenerator->get_Parameters()->set_RotationAngle(0);
barcodeGenerator->Save(u"Code128__Rot0.jpeg");
//--------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
// Create a memory stream object that would store barcode image in binary form
//System::SharedPtr<System::IO::Stream> ms = System::MakeObject<System::IO::MemoryStream>();
//System::SmartPtr<System::IO::Stream> ms = System::MakeObject<System::IO::MemoryStream>(System::SmartPtrMode::Shared);
//System::SmartPtr<System::IO::MemoryStream> ms = System::MakeObject<System::IO::MemoryStream>(System::SmartPtrMode::Shared);
//System::SharedPtr<System::IO::MemoryStream> ms = System::MakeObject<System::IO::MemoryStream>();
//System::SmartPtr<System::IO::MemoryStream> ms = System::MakeObject<System::IO::MemoryStream>(nullptr, System::SmartPtrMode::Shared);
//System::SharedPtr<System::IO::Stream> ms = ms1;
System::SharedPtr<System::IO::Stream> ms = System::MakeObject<System::IO::MemoryStream>();
// Call save method of BarCodeImage to store ‘Png’ barcode image to ‘memory stream’
barcodeGenerator->Save(ms, Aspose::BarCode::BarCodeImageFormat::Png);
ms->set_Position(0);
System::SharedPtr<Aspose::BarCode::BarCodeRecognition::BarCodeReader> reader = System::MakeObject<Aspose::BarCode::BarCodeRecognition::BarCodeReader>(ms, Aspose::BarCode::BarCodeRecognition::DecodeType::Code128);
if(reader->Read())
System::Console::WriteLine(u"\nBarcode from stream recognized as " + reader->GetCodeText() + u"\n\n");
else
System::Console::WriteLine(u"Barcode from stream failed to recognize\n\n");
//--------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
barcodeGenerator->get_Parameters()->get_Barcode()->get_Padding()->get_Top()->set_Millimeters(2.f);
barcodeGenerator->get_Parameters()->get_Barcode()->get_Padding()->get_Left()->set_Millimeters(2.f);
barcodeGenerator->get_Parameters()->get_Barcode()->get_Padding()->get_Right()->set_Millimeters(2.f);
barcodeGenerator->get_Parameters()->get_Barcode()->get_Padding()->get_Bottom()->set_Millimeters(2.f);
barcodeGenerator->get_Parameters()->get_Border()->get_Width()->set_Millimeters(0.5f);
barcodeGenerator->get_Parameters()->get_Border()->set_Visible(true);
//--------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
barcodeGenerator->get_Parameters()->get_Barcode()->get_BarHeight()->set_Millimeters(11);
barcodeGenerator->Save(u"Code39__BarHeight__11mm.png");
barcodeGenerator->get_Parameters()->get_Barcode()->get_BarCodeHeight()->set_Millimeters(4);
barcodeGenerator->Save(u"Code39__BarCodeHeight__4mm.png");
//--------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
// Set the wide to narrow ratio for the barcode //
barcodeGenerator->get_Parameters()->get_Barcode()->set_WideNarrowRatio(9.0f);
barcodeGenerator->Save(u"Code39__WideNarrowRatio__9.png");
//--------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
// Set the symbology and code text and X dimension reduction property of barcode and save barcode Image //
System::SharedPtr<Aspose::BarCode::Generation::BarcodeGenerator> barcodeGenerator1 = [&] { auto tmp_0 = System::MakeObject<Aspose::BarCode::Generation::BarcodeGenerator>(Aspose::BarCode::Generation::EncodeTypes::Code128, u"blackReduction"); tmp_0->get_Parameters()->get_Barcode()->get_XDimension()->set_Millimeters(1.2f); return tmp_0; }();
barcodeGenerator1->Save(u"SetWideNarrowRatio__Code128.png");
//--------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------//
// Create instance of BarcodeGenerator, specify codetext and symbology in the constructor //
System::SharedPtr<Aspose::BarCode::Generation::BarcodeGenerator> barcodeGenerator2 = [&] { auto tmp_0 = System::MakeObject<Aspose::BarCode::Generation::BarcodeGenerator>(Aspose::BarCode::Generation::EncodeTypes::Codabar, u"11112222333344"); tmp_0->get_Parameters()->get_Barcode()->get_Codabar()->set_CodabarStartSymbol(Aspose::BarCode::CodabarSymbol::A); tmp_0->get_Parameters()->get_Barcode()->get_Codabar()->set_CodabarStopSymbol(Aspose::BarCode::CodabarSymbol::D); return tmp_0; }();
barcodeGenerator2->Save(u"Coabar-start-stop-symbols.png");
//--------------------------------------------------------------------------------------//
std::cout << "GenerateCode128(): Ended\n\n";
}
int main()
{
//const System::String licenseFile = u"Aspose.BarCode.lic";
//System::SharedPtrAspose::BarCode::License license = new Aspose::BarCode::License();
//license->SetLicense(licenseFile);
GenerateCode128();
}
***Please help me in get rid of those compilation errors
Thanks and Regards
Kalyan