SkiaSharp.QrCode
SkiaSharp.QrCode copied to clipboard
Add information qr
I would like you to add an extension to write information to the qr code. Here is an example of what it would look like
public static void Render(this SKCanvas canvas, QRCodeData data, int width, int hight, SKColor clearColor, SKColor codeColor, IconData iconData, string iconInfo)
{
var hightInconInfo = 25;
canvas.Clear(clearColor);
using QRCodeRenderer qRCodeRenderer = new QRCodeRenderer();
SKRect area = SKRect.Create(0f, 0f, width, hight + hightInconInfo);
qRCodeRenderer.Render(canvas, area, data, codeColor, null, iconData);
var fontInitNumber = 35;
// draw some text
var paint = new SKPaint
{
Color = SKColors.Black,
IsAntialias = true,
Style = SKPaintStyle.Fill,
TextAlign = SKTextAlign.Center,
TextSize = fontInitNumber
};
float widthicon = width / 100f * (float)iconData.IconSizePercent;
float heigthicon = hight / 100f * (float)iconData.IconSizePercent;
float xicon = width / 2f - widthicon / 2f;
float yicon = hight / 2f - heigthicon / 2f;
var dimText = paint.MeasureText(iconInfo);
while (dimText > widthicon)
{
paint.TextSize = fontInitNumber--;
dimText = paint.MeasureText(iconInfo);
}
var coord = new SKPoint(xicon + (dimText / 2f) + ((widthicon - dimText) / 2f), yicon + heigthicon + 10f);
canvas.DrawText(iconInfo, coord, paint);
}
