ByteScout BarCode Generator SDK - C++ - Monochrome Bitmap - ByteScout

ByteScout BarCode Generator SDK – C++ – Monochrome Bitmap

  • Home
  • /
  • Articles
  • /
  • ByteScout BarCode Generator SDK – C++ – Monochrome Bitmap

ByteScout BarCode Generator SDK – C++ – Monochrome Bitmap

BarcodeGenerationExample.cpp

#include "stdafx.h"

#import "Bytescout.BarCode.tlb" raw_interfaces_only

using namespace Bytescout_BarCode;


int _tmain(int argc, _TCHAR* argv[])
{
	// Initialize COM.
	HRESULT hr = CoInitialize(NULL);

	// Create the interface pointer.
	IBarcodePtr pIBarcode(__uuidof(Barcode));

	// set the registration name and key
	BSTR regname = ::SysAllocString(L"DEMO");
	pIBarcode->put_RegistrationName(regname);
	::SysFreeString(regname);

	BSTR regkey = ::SysAllocString(L"DEMO");
	pIBarcode->put_RegistrationKey(regkey);
	::SysFreeString(regkey);

	// Set barcode type (symbology)
	pIBarcode->put_Symbology(SymbologyType_DataMatrix);

	// Set monochrome output 
	pIBarcode->put_ProduceMonochromeImages(VARIANT_TRUE);

	// Set barcode value
	BSTR value = ::SysAllocString(L"Barcode Value 1234567890");
	pIBarcode->put_Value(value);
	::SysFreeString(value);

	// Save barcode image
	BSTR fileName = ::SysAllocString(L"result.png");
	pIBarcode->SaveImage(fileName);
	::SysFreeString(fileName);

	pIBarcode->Release();

	// Uninitialize COM.
	CoUninitialize();

	return 0;
}


stdafx.cpp

// stdafx.cpp : source file that includes just the standard includes
// BarcodeGenerationExample.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next