I used QRCoder in order to generate a random QR code when clicking a button like so:
private void OnRNGClicked(object sender, EventArgs e)
{
//Generates a "random" number to be used when making the QR Code
Random rng = new Random();
int sixDigRNG = rng.Next(1, 11);
string rngString = sixDigRNG.ToString();
//Creates the QR Code
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(rngString, QRCodeGenerator.ECCLevel.L);
PngByteQRCode qRCode = new PngByteQRCode(qrCodeData);
//Displays the QR Code
byte[] qrCodeBytes = qRCode.GetGraphic(20);
QrCodeImage.Source = ImageSource.FromStream(() => new MemoryStream(qrCodeBytes));
}
I want to have another button that when clicked will use the Save method to save this png QR Code to whichever type of platform the user is using (Android, IOS, Windows ect...). My issue is that whenever I try to use the Save method (Documentation: https://learn.microsoft.com/en-us/dotnet/api/system.drawing.image.save?view=dotnet-plat-ext-8.0) it says that there is no definition for this method. I think it might be because I am generating a QR instead of editing an image. Any suggestions?
Thank you in advance!
I have also tried using System.Windows.Forms to make a form for the user to save the image with, but my .NET MAUI application did not recognize this namespace.
try this
docs