Creating a class:
public class QRCodeEncoderDemo
{
public static System.Drawing.Bitmap CombinImage(System.Drawing.Bitmap bit,string destImg)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(destImg);
if (img.Height != 45 || img.Width != 45)
{
img = KiResizeImage(img, 45, 45, 0);
}
Graphics g = Graphics.FromImage(bit);
g.DrawImage(bit, 0, 0, bit.Width, bit.Height);
g.DrawImage(img, bit.Width / 2 - img.Width / 2, bit.Width / 2 - img.Width / 2, img.Width, img.Height);
GC.Collect();
return bit;
}
public static System.Drawing.Image KiResizeImage(System.Drawing.Image bmp, int newW, int newH, int Mode)
{
try
{
System.Drawing.Image b = new Bitmap(newW, newH);
Graphics g = Graphics.FromImage(b);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(bmp, new System.Drawing.Rectangle(0, 0, newW, newH), new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
g.Dispose();
return b;
}
catch
{
return null;
}
}
internal System.Drawing.Image GCode(object p)
{
throw new NotImplementedException();
}
}
Using the class:
bitmap = encoder.Encode(textQr.Text);
bitmap = QRCodeEncoderDemo.CombinImage(bitmap, fileName);