public Bitmap hexaDecimalQRCode(Name _companyName,
VATNum _vatNum,
CustInvoiceId _invoiceId,
CreatedDateTime _transdate,
AmountCurNet _netAmt,
Amount _vatAmt)
{
str hexaDecimalSellerTag,hexaDecimalVATNumberTag,hexaDecimalTimeStampTag,hexaDecimalInvoiceTotalTag,hexaDecimalVATTotalTag;
int hexaDecimalSellerLength,hexaDecimalVATNumberLength,hexaDecimalTimeStampLength,hexaDecimalInvoiceTotalLength,hexaDecimalVATTotalLength;
str hexaDecimalSellerValue,hexaDecimalVATNumberValue,hexaDecimalTimeStampValue,hexaDecimalInvoiceTotalValue,hexaDecimalVATTotalValue;
str hexaDecimalSeller,hexaDecimalVATNumber,hexaDecimalTimeStamp,hexaDecimalInvoiceTotal,hexaDecimalVATTotal;
Str Seller,VATNumber,TimeStamp,InvoiceTotal,VATTotal,hexaDecimal,tempValue,base64Text;
System.Byte[] byte;
bindata bindata;
container con;
int i;
container qrCode,conStore;
Microsoft.Dynamics.ApplicationSuite.QRCode.Encoder qrCode1 = new Microsoft.Dynamics.ApplicationSuite.QRCode.Encoder();
System.Drawing.Bitmap bitmap;
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
container imageContainer;
hexaDecimalSellerTag = "01";
hexaDecimalVATNumberTag = "02";
hexaDecimalTimeStampTag = "03";
hexaDecimalInvoiceTotalTag = "04";
hexaDecimalVATTotalTag = "05";
Seller = _companyName;
VATNumber = strFmt("%1",_vatNum);
TimeStamp = "2021-12-22 09:26:31";//DateTimeUtil::toStr(_transdate);//"2021-11-01 11:30:28";//"3/26/2018 01:28:18";//strFmt("%1",_transdate);//"2021-11-01 21:30:00";
InvoiceTotal = strFmt("%1",_netAmt);
VATTotal = strFmt("%1",_vatAmt);
hexaDecimalSellerLength = strLen(Seller);
hexaDecimalVATNumberLength = strLen(VATNumber);
hexaDecimalTimeStampLength = strLen(TimeStamp);
hexaDecimalInvoiceTotalLength = strLen(InvoiceTotal);
hexaDecimalVATTotalLength = strLen(VATTotal);
hexaDecimalSellerValue = int2Hex(hexaDecimalSellerLength);
hexaDecimalVATNumberValue = int2Hex(hexaDecimalVATNumberLength);
hexaDecimalTimeStampValue = int2Hex(hexaDecimalTimeStampLength);
hexaDecimalInvoiceTotalValue = int2Hex(hexaDecimalInvoiceTotalLength);
hexaDecimalVATTotalValue = int2Hex(hexaDecimalVATTotalLength);
if(strLen(hexaDecimalSellerValue) == 1)
{
hexaDecimalSellerValue = "0" + hexaDecimalSellerValue;
}
if(strLen(hexaDecimalVATNumberValue) == 1)
{
hexaDecimalVATNumberValue = "0" + hexaDecimalVATNumberValue;
}
if(strLen(hexaDecimalTimeStampValue) == 1)
{
hexaDecimalTimeStampValue = "0" + hexaDecimalTimeStampValue;
}
if(strLen(hexaDecimalInvoiceTotalValue) == 1)
{
hexaDecimalInvoiceTotalValue = "0" + hexaDecimalInvoiceTotalValue;
}
if(strLen(hexaDecimalVATTotalValue) == 1)
{
hexaDecimalVATTotalValue = "0" + hexaDecimalVATTotalValue;
}
for (i=1;i<=hexaDecimalSellerLength ;i++)
{
hexaDecimalSeller += int2Hex(char2num(Seller,i));
}
for (i=1;i<=hexaDecimalVATNumberLength ;i++)
{
hexaDecimalVATNumber += int2Hex(char2num(VATNumber,i));
}
for (i=1;i<=hexaDecimalTimeStampLength ;i++)
{
hexaDecimalTimeStamp += int2Hex(char2num(TimeStamp,i));
}
for (i=1;i<=hexaDecimalInvoiceTotalLength ;i++)
{
hexaDecimalInvoiceTotal += int2Hex(char2num(InvoiceTotal,i));
}
for (i=1;i<=hexaDecimalVATTotalLength ;i++)
{
hexaDecimalVATTotal += int2Hex(char2num(VATTotal,i));
}
hexaDecimal = hexaDecimalSellerTag + hexaDecimalSellerValue +hexaDecimalSeller + hexaDecimalVATNumberTag + hexaDecimalVATNumberValue + hexaDecimalVATNumber + hexaDecimalTimeStampTag
+ hexaDecimalTimeStampValue + hexaDecimalTimeStamp + hexaDecimalInvoiceTotalTag + hexaDecimalInvoiceTotalValue + hexaDecimalInvoiceTotal + hexaDecimalVATTotalTag + hexaDecimalVATTotalValue + hexaDecimalVATTotal;
//hexaDecimal = "011153656465722048656164204f6666696365020f3330303034393035353231303030330313323032312d31322d32322030393a32363a3331040331313105063734342e3135";
con = BinData::stringToData(hexadecimal);
bindata = new bindata();
bindata.setData(con);
base64Text = bindata.base64Encode();
//base64Text = "ARFTZWRlciBIZWFkIE9mZmljZQIPMzAwMDQ5MDU1MjEwMDAzAxMyMDIxLTEyLTIyIDA5OjI2OjMxBAMxMTEFBjc0NC4xNQ==";
bitmap=qrCode1.Encode(base64Text);
bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat::get_Jpeg());//get_Jpeg
imageContainer=Binary::constructFromMemoryStream(memoryStream).getContainer();
qrCode = imageContainer;
return qrCode;
}
public bitmap qrBitMap(str _qrString)
{
Microsoft.Dynamics.ApplicationSuite.QRCode.Encoder qrCode1 = new Microsoft.Dynamics.ApplicationSuite.QRCode.Encoder();
System.Drawing.Bitmap bitmap;
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
container imageContainer;
container qrCode,conStore;
bitmap=qrCode1.Encode(_qrString);
bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat::get_Jpeg());//get_Jpeg
imageContainer=Binary::constructFromMemoryStream(memoryStream).getContainer();
qrCode = imageContainer;
return qrCode;
}
Use bitmap to display QR (Image/bmp)