Example #1
0
        private void ShowQRCodeMask(Result result, Bitmap QRImage)
        {
            QRCodeSplashForm splash = new QRCodeSplashForm();

            splash.Panel.BackColor = picMaskColor.BackColor;

            float  minX = int.MaxValue, minY = int.MaxValue, maxX = 0, maxY = 0;
            object orientation = 0;
            float  Angle       = 0;

            if (result.ResultMetadata.ContainsKey(ResultMetadataType.ORIENTATION))
            {
                result.ResultMetadata.TryGetValue(ResultMetadataType.ORIENTATION, out orientation);
                Angle = (float)((int)orientation * Math.PI / 180);
            }
            foreach (ResultPoint point in result.ResultPoints)
            {
                float x = point.X;
                float y = point.Y;
                if (Angle != 0)
                {
                    //x = QRImage.Width - (float)Math.Abs(point.X * Math.Cos(Angle) - point.Y * Math.Sin(Angle));
                    //y = QRImage.Height - (float)Math.Abs(point.Y * Math.Cos(Angle) + point.X * Math.Sin(Angle));
                    x = QRImage.Width - (float)Math.Abs(point.X * Math.Cos(Angle) + point.Y * Math.Sin(Angle));
                    y = (float)Math.Abs(-point.Y * Math.Cos(Angle) + point.X * Math.Sin(Angle));
                }

                minX = Math.Min(minX, x);
                minY = Math.Min(minY, y);
                maxX = Math.Max(maxX, x);
                maxY = Math.Max(maxY, y);
            }

            Point mark       = new Point((int)minX, (int)minY);
            Size  size       = new Size((int)(maxX - minX), (int)(maxY - minY));
            float pixelWidth = calcBorderWidth(QRImage, mark, size);
            float margin     = pixelWidth * 3;

            minX           -= margin;
            maxX           += margin;
            minY           -= margin;
            maxY           += margin;
            splash.Location = new Point((int)minX, (int)minY);
            // we need a panel because a window has a minimal size
            splash.Panel.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY);
            splash.Size       = splash.Panel.Size;
            splash.Show();
            System.Threading.Thread.Sleep(250);
            splash.Close();
        }
Example #2
0
        private void ShowQRCodeMask(Result result, Bitmap QRImage)
        {
            QRCodeSplashForm splash = new QRCodeSplashForm();
            splash.Panel.BackColor = picMaskColor.BackColor;

            float minX = int.MaxValue, minY = int.MaxValue, maxX = 0, maxY = 0;
            object orientation = 0;
            float Angle = 0;
            if (result.ResultMetadata.ContainsKey(ResultMetadataType.ORIENTATION))
            {
                result.ResultMetadata.TryGetValue(ResultMetadataType.ORIENTATION, out orientation);
                Angle = (float)((int)orientation * Math.PI / 180);
            }
            foreach (ResultPoint point in result.ResultPoints)
            {
                float x = point.X;
                float y = point.Y;
                if (Angle != 0)
                {
                    //x = QRImage.Width - (float)Math.Abs(point.X * Math.Cos(Angle) - point.Y * Math.Sin(Angle));
                    //y = QRImage.Height - (float)Math.Abs(point.Y * Math.Cos(Angle) + point.X * Math.Sin(Angle));
                    x = QRImage.Width - (float)Math.Abs(point.X * Math.Cos(Angle) + point.Y * Math.Sin(Angle));
                    y = (float)Math.Abs(-point.Y * Math.Cos(Angle) + point.X * Math.Sin(Angle));
                }

                minX = Math.Min(minX, x);
                minY = Math.Min(minY, y);
                maxX = Math.Max(maxX, x);
                maxY = Math.Max(maxY, y);
            }

            Point mark = new Point((int)minX, (int)minY);
            Size size = new Size((int)(maxX - minX), (int)(maxY - minY));
            float pixelWidth = calcBorderWidth(QRImage, mark, size);
            float margin = pixelWidth * 3;
            minX -= margin;
            maxX += margin;
            minY -= margin;
            maxY += margin;
            splash.Location = new Point((int)minX, (int)minY);
            // we need a panel because a window has a minimal size
            splash.Panel.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY);
            splash.Size = splash.Panel.Size;
            splash.Show();
            System.Threading.Thread.Sleep(250);
            splash.Close();
        }