I want to generate a qr code with a logo inside.
The logo is appearing fine, but I can't change the size of the logo.
I tried playing around with ImageWidth and ImageHeight but it doesn't seem to have any effect.
- Code: Select all
BarcodeSettings settings = new BarcodeSettings
{
Type = BarCodeType.QRCode,
QRCodeECL = QRCodeECL.M,
ShowText = false,
X = 5f,
Data = vCardContent.ToString(),
ForeColor = Color.Gray,
Unit = (int)GraphicsUnit.Pixel,
ImageWidth = Convert.ToInt64(250),
ImageHeight = Convert.ToInt64(250),
Data2D = vCardContent.ToString(),
QRCodeLogoImage = Image.FromFile(_environment.ContentRootPath + $"/assets/images/logo.jpg")
};
BarCodeGenerator generator = new BarCodeGenerator(settings);
Image image = generator.GenerateImage();
MemoryStream ms = new MemoryStream();
image.Save(ms, ImageFormat.Png);
ms.Position = 0;
return new FileStreamResult(ms, "image/png");