private static string CreateQR(IntPtr ptrFileInformation, dynamic payload) { var FileInformation = new QRFileInfo(ptrFileInformation); QRCode qrCode = GenerateQR(payload); if (FileInformation.SaveImage) { if (FileInformation.FileName == "") { return(""); } if (File.Exists(FileInformation.FileName)) { File.Delete(FileInformation.FileName); } qrCode.GetGraphic(20).Save(FileInformation.FileName, FileInformation.FileType); return(""); } return(Convert.ToBase64String(ImageToByte2(qrCode.GetGraphic(20), new QRFileInfo(ptrFileInformation)))); }
private static byte[] ImageToByte2(Image img, QRFileInfo fileInformation) { using var stream = new MemoryStream(); img.Save(stream, fileInformation.FileType); return(stream.ToArray()); }