2019-09-29 09:47:06 -07:00
|
|
|
|
using System.Drawing;
|
|
|
|
|
using PKHeX.Core;
|
|
|
|
|
using QRCoder;
|
|
|
|
|
|
2021-12-10 00:15:04 -08:00
|
|
|
|
namespace PKHeX.Drawing.Misc;
|
|
|
|
|
|
|
|
|
|
public static class QREncode
|
2019-09-29 09:47:06 -07:00
|
|
|
|
{
|
2021-12-10 00:15:04 -08:00
|
|
|
|
public static Image GenerateQRCode(DataMysteryGift mg) => GenerateQRCode(QRMessageUtil.GetMessage(mg));
|
2022-06-18 11:04:24 -07:00
|
|
|
|
public static Image GenerateQRCode(PKM pk) => GenerateQRCode(QRMessageUtil.GetMessage(pk));
|
2019-09-29 09:47:06 -07:00
|
|
|
|
|
2021-12-10 00:15:04 -08:00
|
|
|
|
public static Image GenerateQRCode7(PK7 pk7, int box = 0, int slot = 0, int copies = 1)
|
|
|
|
|
{
|
|
|
|
|
byte[] data = QR7.GenerateQRData(pk7, box, slot, copies);
|
|
|
|
|
var msg = QRMessageUtil.GetMessage(data);
|
|
|
|
|
return GenerateQRCode(msg, ppm: 4);
|
|
|
|
|
}
|
2019-09-29 09:47:06 -07:00
|
|
|
|
|
2021-12-10 00:15:04 -08:00
|
|
|
|
private static Image GenerateQRCode(string msg, int ppm = 4)
|
|
|
|
|
{
|
|
|
|
|
using var generator = new QRCodeGenerator();
|
|
|
|
|
using var data = generator.CreateQrCode(msg, QRCodeGenerator.ECCLevel.Q);
|
|
|
|
|
using var code = new QRCode(data);
|
|
|
|
|
return code.GetGraphic(ppm);
|
2019-09-29 09:47:06 -07:00
|
|
|
|
}
|
2021-12-10 00:15:04 -08:00
|
|
|
|
}
|