locked
Set Image Property Type in code by directly setting the byte array value... RRS feed

  • Question

  • Greetings - 

    I am writing a LS app that will generate a unique QR code (using ZXing library) per subject and display that subjects QRCode image on screen.

    ex: table called "subjects" w/ firstName(string), lastName(string), and QrCodeImage (image).

    for now, I've added a command button to show on screen for each subject entry...

    At the last step, i set the 'QrCodeImage' (which is a byte) to the value of 'qrCodeByteArray'...i can see the value is set and the screen (using the standard LS image editor control) shows that there is something there (does a little flicker and even lets me delete) but the QRCode is not showing in the UI.

    I've tried to change all the size options, thinking it was too big, too small, etc....no luck.  

    I'm wondering if I need to be doing something else to set properly set the byte property?

    Thanks!!!!!!

    ######### code ##############

    partial void CreateQrCode_Execute()
            {
                //// needed to prevent "invalid cross thread access..." error.
                Dispatchers.Main.BeginInvoke(() =>
                {
                    //// using ZXing to create QRCode...
                    var barCodeWriter = new BarcodeWriter
                    {
                        Format = BarcodeFormat.QR_CODE,
                        Options = new EncodingOptions { Height = 10, Width = 10 }
                    };

                    //// result is a WriteableBitMap
                    var result = barCodeWriter.Write("The quick brown fox jumps over the lazy dog.");

                    //// convert the result (WriteableBitMap) to a ByteArray
                    //// 'QrCodeImage' is an 'Image' type...
                    var qrCodeByteArray = result.ToByteArray();

                    //// set the qrimage (image type) to the byteArray value...
                    this.Subjects.SelectedItem.QrCodeImage = qrCodeByteArray;

                    //// random junk to hit break point...
                    string something = "nothing";

                });
            }


    • Edited by ihayes916 Tuesday, November 5, 2013 11:58 PM added screen shot showing values at break points....
    Tuesday, November 5, 2013 11:56 PM

Answers

  • Hi ihayes

    Thanks for your feedback.

    According to your description, it seems that the data isn't formatted correnctly before display in the UI, I think this is UI specific issue, and UI can't recognize this image properly.

    Regards

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by Angie Xu Monday, November 25, 2013 2:07 AM
    Wednesday, November 20, 2013 8:00 AM

All replies

  • #######  update #######

    I've been working on this more and I've added code to save the image to my desktop (directly from the DB)...and that does work - i have legit qrcodes - so the data seems to be formatted correctly, but it just does not show in the UI...help..please.  :)


    Thursday, November 7, 2013 3:31 AM
  • Hi ihayes

    Thanks for your feedback.

    According to your description, it seems that the data isn't formatted correnctly before display in the UI, I think this is UI specific issue, and UI can't recognize this image properly.

    Regards

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Marked as answer by Angie Xu Monday, November 25, 2013 2:07 AM
    Wednesday, November 20, 2013 8:00 AM