예제 #1
0
        private void m_btnGenerate_Click(object sender, EventArgs e)
        {
            string            content         = m_txtContent.Text;
            QRCorrectionLevel correctionLevel = m_cmbCorrection.SelectedItem as QRCorrectionLevel;

            QRImageRenderer.ImageScale scale = (QRImageRenderer.ImageScale)m_cmbScale.SelectedItem;

            try
            {
                Generate(content, correctionLevel, scale);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void Generate(string content, QRCorrectionLevel correctionLevel, QRImageRenderer.ImageScale scale)
        {
            Matrix = null;
            Matrix = QREncoderMatrix.Encode(content, correctionLevel);

            using (MemoryStream stream = new MemoryStream())
            {
                Matrix.ToBMP(stream, scale: scale);
                stream.Flush();

                TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
                Bitmap        bmp       = converter.ConvertFrom(stream.ToArray()) as Bitmap;

                m_pnlImage.BackgroundImage = bmp;
                m_txtTrace.Text            = Matrix.ToString();
            }
        }