none
Save Qrcode to Image Png RRS feed

All replies

  • Can you please explain in more detail what you mean?

    Are you trying to generate a Qrcode? If so you'll need to use a 3rd party library such as ZXing.Net as there isn't anything provided in box.

    If you already have an image and are asking about converting it to a PNG then what format do you already have? You can use the BitmapDecoder and BitmapEncoder to convert that to a PNG.

    --Rob

    Monday, December 11, 2017 8:56 PM
  • I using Qrcode.net,   I want to save as image the Qrcode in the image folder.
    Monday, December 11, 2017 9:12 PM
  • For help specifically with QRCode.net you'll need to contact its authors.

    From a quick look at its page it can provide data in several different forms. What type of data are you getting from it?

    If you can get unencoded pixels then you can encode it to PNG with BitmapEncoder. If you get encoded pixels in a non-PNG bitmap format then you can decode them with BitmapDecoder and then encode to PNG with BitmapEncoder.

    Monday, December 11, 2017 10:11 PM
  • Then it is better to use ZXing.Net
    Tuesday, December 12, 2017 8:43 AM
  • I want to save Qr which is an image in PNG format.
    Wednesday, December 13, 2017 9:11 PM
  • We can't help you unless you can provide more information about what exactly you're trying to do, what information you can get from your library, and what you need to do with it.

    If you already have the image in PNG format that what else do you want to do with it?

    Thursday, December 14, 2017 2:41 AM
  • The image is not in PNG format, when I have the QR I want to be saved in PNG format in the folder, I'm using QRCoder
    Thursday, December 14, 2017 8:28 AM
  • I am do with this:

    QRCoder

    Thursday, December 14, 2017 10:50 AM
  • This part creates the QR

    private async void btCrear_Click(object sender, RoutedEventArgs e)
            {
    
                //create generator
    
                var level = SelectedEcc;
                var ecclevel = (QRCodeGenerator.ECCLevel)(level == "L" ? 0 : level == "M" ? 1 : level == "Q" ? 2 : 3);
    
                QRCodeGenerator qrGenerator = new QRCodeGenerator();
                QRCodeData qrCodeData = qrGenerator.CreateQrCode(NameText, ecclevel);
                BitmapByteQRCode qrCodePng = new BitmapByteQRCode(qrCodeData);
    
                byte[] qrCodeImagePng = qrCodePng.GetGraphic(20, new byte[] { 23, 16, 16 }, new byte[] { 255, 255, 255 });
    
                using (InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream())
                {
                    using (DataWriter writer = new DataWriter(stream.GetOutputStreamAt(0)))
                    {
                        writer.WriteBytes(qrCodeImagePng);
    
                        await writer.StoreAsync();
                    }
    
                    var image = new BitmapImage();
                    await image.SetSourceAsync(stream);
                    imageqrcode.Source = image;
                }
            }
    


    Thursday, December 14, 2017 11:13 AM
  • How save   image en File system,  jpg ?
    Monday, December 18, 2017 4:51 PM
  • For help with using QRCode.Net you'll need to ask its authors.

    Assuming that your code has generated a PNG file into the InMemoryRandomAccessStream you can save it to a file by copying that to a StorageFile. Alternatively, you can write it directly to a StorageFile's stream rather than going through the InMemoryRandomAccessStream.

    If you have direct pixel values rather than an encoded png then you will need to pass that to a BitmapEncoder to convert it to a PNG or JPG first. 

    See the following documentation and samples:

    • https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/imaging#save-a-softwarebitmap-to-a-file-with-bitmapencoder
    • https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/imaging#transcode-an-image-file
    • https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/SimpleImaging
    Monday, December 18, 2017 6:29 PM