I use ZXing.Net library to generate a QR code image -
At the top of my class:
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
My method:
protected void UpdateQRSource(String address)
{
QRCodeWriter qrcode = new QRCodeWriter();
BarcodeWriter barcodeWriter = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions
{
Width = 300,
Height = 300,
Margin = 4
}
};
using (Bitmap bitmap = barcodeWriter.Write(address))
{
IntPtr hbmp = bitmap.GetHbitmap();
try
{
BitmapSource source = Imaging.CreateBitmapSourceFromHBitmap(
hbmp,
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
qrImage.Source = source; // set WPF image source
}
finally
{
DeleteObject(hbmp);
}
}
}
Please advise me how to add short text string or a custom image in the middle of the QR code - similar to the Wikipedia visual QR code below:
UPDATE:
Embedding custom logo in QR code (without breaking the latter!) seems to be not a trivial task as the scientific publication QR Images: Optimized Image Embedding in QR Codes shows...
But I still wonder if I could generate a QR code (as in the above source code), then overlay it with a custom text or logo, then validate the resulting image again by ZXing.Net.