Пример #1
0
        public object CreateQRCode(byte[] bytesToCode)
        {
            QRCodeBytes  qr   = new QRCodeBytes(bytesToCode);
            QRCodeWriter qrwr = new QRCodeWriter(qr.Service, qr.ToWrite);

            return(null);
        }
Пример #2
0
            private void WriteDataWithMask(Func <int, int, bool> mask)
            {
                bool[] toWriteBits = QRCodeBytes.BytesToBits(ToWrite.ToArray()).ToArray();//Clone
                int    dataIndex   = 0;
                int    x           = QRGrid.Length - 1;
                int    y           = QRGrid.Length - 1;
                bool   top         = true; //true - top

                while (dataIndex != toWriteBits.Length)
                {
                    if (top)
                    {
                        if (TrySetPixel(y, x, toWriteBits.Length > dataIndex ? toWriteBits[dataIndex]:false, mask))
                        {
                            dataIndex++;
                        }
                        x--;
                        if (TrySetPixel(y, x, toWriteBits.Length > dataIndex ? toWriteBits[dataIndex] : false, mask))
                        {
                            dataIndex++;
                        }
                        x++;
                        y--;
                    }
                    else
                    {
                        if (TrySetPixel(y, x, toWriteBits.Length > dataIndex ? toWriteBits[dataIndex] : false, mask))
                        {
                            dataIndex++;
                        }
                        x--;
                        if (TrySetPixel(y, x, toWriteBits.Length > dataIndex ? toWriteBits[dataIndex] : false, mask))
                        {
                            dataIndex++;
                        }
                        x++;
                        y++;
                    }
                    if (y < 0)
                    {
                        x  -= 2;
                        y   = 0;
                        top = false;
                    }
                    else if (y >= QRGrid.Length)
                    {
                        x  -= 2;
                        y   = QRGrid.Length - 1;
                        top = true;
                    }
                    if (x == 6)
                    {
                        x--;
                    }
                    if (x < 0)
                    {
                        break;
                    }
                }
                Console.WriteLine("dataIndex: " + dataIndex);
                Console.WriteLine("toWriteBits.Length: " + toWriteBits.Length);
            }