Example #1
0
    public void pdfTest()
    {
        RawImage rawImage = gameObject.AddComponent <RawImage>();

        string          sentence          = bipSeed;
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(sentence, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        rawImage.texture = qrCodeAsTexture2D;
        byte[] bytes = qrCodeAsTexture2D.EncodeToJPG(); // .EncodeToPNG();

        pdfDocument myDoc  = new sharpPDF.pdfDocument("qr_pdf_test", "qr tester");
        pdfPage     myPage = myDoc.addPage(500, 500);

        myPage.addImage(bytes, 1, 150, 200, 200);

        myPage.addText("Your seed entropy is: ", 10, 470, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText(hexSeed, 10, 450, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText(bipSeed, 10, 425, sharpPDF.Enumerators.predefinedFont.csCourier, 10);

        // need to change this code depending on the current operating system/build type
        myDoc.createPDF("qr_pdf_test.pdf");
        myPage = null;
        myDoc  = null;
    }
Example #2
0
        private void RegenerateQR()
        {
            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(selectedQR.Id, QRCodeGenerator.ECCLevel.Q);
            UnityQRCode     qrCode      = new UnityQRCode(qrCodeData);

            qrCodeImage = qrCode.GetGraphic(20);
            // qrCodeImage = FlipTexture(qrCodeImage, false, true);
        }
Example #3
0
    /**
     * Generates a QRcode texture from a string
     **/
    private Texture2D GenerateQRcode(string data)
    {
        QRCodeGenerator qrGenerator = new QRCodeGenerator();
        QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode      = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeImage = qrCode.GetGraphic(32);

        return(qrCodeImage);
    }
Example #4
0
    public void ValueChangeCheck()
    {
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(mainInputField.text, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        GameObject.Find("Cube").GetComponent <Renderer>().material.mainTexture = qrCodeAsTexture2D;
    }
Example #5
0
    private static Texture2D GenerateTextureQR(string text, int pixelsPerModule)
    {
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(pixelsPerModule);

        return(qrCodeAsTexture2D);
    }
Example #6
0
        static Texture2D GenerateQRCodeTexture(int pixelsPerModule, string qrString, int margin)
        {
            QRCodeGenerator qrGenerator       = new QRCodeGenerator();
            QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(qrString, QRCodeGenerator.ECCLevel.Q);
            UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
            Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(pixelsPerModule);

            return(qrCodeAsTexture2D);
        }
    public void testWithRawImage()
    {
        rawImage = GetComponent <RawImage>();
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode("ugly call give address amount venture misery dose quick spoil weekend inspire", QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        rawImage.texture = qrCodeAsTexture2D;
    }
    public void setRawImage(string sentence)
    {
        rawImage = GetComponent <RawImage>();
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(sentence, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        rawImage.texture = qrCodeAsTexture2D;
    }
    public void saveToFile(string sentence)
    {
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(sentence, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        byte[] bytes = qrCodeAsTexture2D.EncodeToPNG();

        File.WriteAllBytes(Application.dataPath + "/../SavedQRCode.png", bytes);
    }
 private void GenerateQR(string policyUrl)
 {
     if (!string.IsNullOrEmpty(policyUrl))
     {
         QRCodeGenerator qrGenerator       = new QRCodeGenerator();
         QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(policyUrl, QRCodeGenerator.ECCLevel.Q);
         UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
         Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);
         Sprite          qrSprite          = Sprite.Create(qrCodeAsTexture2D, new Rect(0, 0, qrCodeAsTexture2D.width, qrCodeAsTexture2D.height),
                                                           new Vector2(qrCodeAsTexture2D.width / 2, qrCodeAsTexture2D.height / 2));
         StartCoroutine(SmoothQrChange(qrSprite));
     }
 }
    // ----------------------------------------------------------------
    public void GenerateQR(string url)
    {
        QRCoder.PayloadGenerator.Url generator = new QRCoder.PayloadGenerator.Url(url);
        string payload = generator.ToString();

        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        rawImageQR.texture = qrCodeAsTexture2D;
        rawImageQR.DOFade(1, 0.3f);
    }
Example #12
0
        private static Texture2D GetQRTexture(QRCodeDataControl qr)
        {
            if (!qrCodeIds.ContainsKey(qr) || qrCodeIds[qr] != qr.Id)
            {
                QRCodeGenerator qrGenerator = new QRCodeGenerator();
                QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(qr.Id, QRCodeGenerator.ECCLevel.Q);
                UnityQRCode     qrCode      = new UnityQRCode(qrCodeData);
                qrCodeIds[qr]      = qr.Id;
                qrCodeTextures[qr] = qrCode.GetGraphic(20);
            }

            return(qrCodeTextures[qr]);
        }
 // Crea la texture del QR Code corrispondente alla string in input
 public Texture2D CreateQRCode(string payload)
 {
     try
     {
         QRCodeGenerator generator = new QRCodeGenerator();
         QRCodeData      data      = generator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.H);
         UnityQRCode     qrCode    = new UnityQRCode(data);
         return(qrCode.GetGraphic(20));
     }
     catch (Exception e)
     {
         Debug.LogError(e.Message);
     }
     return(null);
 }
Example #14
0
    public void pdfTest()
    {
        string          sentence          = "ugly call give address amount venture misery dose quick spoil weekend inspire";
        QRCodeGenerator qrGenerator       = new QRCodeGenerator();
        QRCodeData      qrCodeData        = qrGenerator.CreateQrCode(sentence, QRCodeGenerator.ECCLevel.Q);
        UnityQRCode     qrCode            = new UnityQRCode(qrCodeData);
        Texture2D       qrCodeAsTexture2D = qrCode.GetGraphic(20);

        rawImage.texture = qrCodeAsTexture2D;
        byte[] bytes = qrCodeAsTexture2D.EncodeToJPG(); // .EncodeToPNG();

        pdfDocument myDoc  = new sharpPDF.pdfDocument("qr_pdf_test", "qr tester");
        pdfPage     myPage = myDoc.addPage(500, 500);

        myPage.addImage(bytes, 1, 150, 200, 200);

        myPage.addText("Your seed entropy is: ", 10, 470, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText("0x3720B025A102812744F830F55DDA275C5", 10, 450, sharpPDF.Enumerators.predefinedFont.csCourier, 15);
        myPage.addText("ugly call give address amount venture misery dose quick spoil weekend inspire", 10, 425, sharpPDF.Enumerators.predefinedFont.csCourier, 10);

        myDoc.createPDF("qr_pdf_test.pdf");
        myPage = null;
        myDoc  = null;
    }
Example #15
0
        public static string CaptureWithQRText(string text)
        {
            if (text == null || text.Equals(""))
            {
                return(null);
            }

            String path = null;

            try
            {
                int width  = Screen.width;
                int height = Screen.height;

                Texture2D texMain = new Texture2D(width, height, TextureFormat.RGB24, false);

                texMain.ReadPixels(new Rect(0, 0, width, height), 0, 0, true);

                texMain.Apply();

                int smallerEdge   = width > height ? height : width;
                int expectQRWidth = Mathf.FloorToInt(smallerEdge * qrSizeFactor);
                if (expectQRWidth < minTargetQRWidth)
                {
                    expectQRWidth = minTargetQRWidth;
                }
                QRCodeGenerator qrGenerator = new QRCodeGenerator();
                QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
                Texture2D       texQR       = new UnityQRCode(qrCodeData).GetGraphic(Mathf.CeilToInt(expectQRWidth / qrCodeData.ModuleMatrix.Count));

                int texQRWidth = texQR.width;

                int     qrX        = 0;
                int     qrY        = 0;
                Color[] qrColorArr = texQR.GetPixels(0, 0, texQRWidth, texQRWidth);
                texMain.SetPixels(qrX, qrY, texQRWidth, texQRWidth, qrColorArr);

                String dir = Application.persistentDataPath + "/" + "screenshot/";
                path = dir + screenShotFileName + ".png";

                var imagebytes = texMain.EncodeToPNG();
                PlatExt.PlatDependant.CreateFolder(dir);
                PlatExt.PlatDependant.DeleteFile(path);
                using (var stream = PlatExt.PlatDependant.OpenWrite(path))
                {
                    stream.Write(imagebytes, 0, imagebytes.Length);
                }


                GameObject.DestroyImmediate(texMain);
                GameObject.DestroyImmediate(texQR);
            }
            catch (System.Exception e)
            {
                if (GLog.IsLogInfoEnabled)
                {
                    GLog.LogInfo("ScreenCaptrueError:" + e);
                }
            }

            return(path);
        }