// initialization
        private void OnLoad(object sender, EventArgs e)
        {
            // program title
            Text = "Pdf417DecoderDemo - " + Pdf417Decoder.VersionNumber + " \u00a9 2019 Uzi Granot. All rights reserved.";

                #if DEBUG
            // current directory
            string CurDir  = Environment.CurrentDirectory;
            string WorkDir = CurDir.Replace("bin\\Debug", "Work");
            if (WorkDir != CurDir && Directory.Exists(WorkDir))
            {
                Environment.CurrentDirectory = WorkDir;
            }

            // open trace file
            Pdf417Trace.Open("Pdf417DecoderTrace.txt");
            Pdf417Trace.Write("Pdf417DecoderDemo");
                #endif

            // create decoder
            Pdf417Decoder = new Pdf417Decoder();

            // resize window
            OnResize(sender, e);
            return;
        }
Beispiel #2
0
        internal static void TraceImage
        (
            Pdf417Decoder Pdf417Decoder,
            int CenterX,
            int CenterY,
            int Left,
            int Top,
            int Right,
            int Bottom
        )
        {
            int Width  = Left + Right + 1;
            int Height = Top + Bottom + 1;

            int OrgX = CenterX - Left;
            int OrgY = CenterY - Top;

            char[] Line = new char[Width + 1];

            for (int Y = 0; Y < Height; Y++)
            {
                Line[0] = Y == Top ? '>' : ' ';
                int R = OrgY + Y;
                for (int X = 0; X < Width; X++)
                {
                    int C = OrgX + X;
                    if (R < 0 || R >= Pdf417Decoder.ImageHeight || C < 0 || C >= Pdf417Decoder.ImageWidth)
                    {
                        Line[X + 1] = ' ';
                    }
                    else
                    {
                        Line[X + 1] = Pdf417Decoder.ImageMatrix[R, C] ? 'X' : '.';
                    }
                }
                Pdf417Trace.Write(new string(Line));
            }
            return;
        }
        /// <summary>
        /// Program initialization
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event arguments</param>
        private void OnLoad(object sender, EventArgs e)
        {
            // program title
            Text = "Pdf417VideoDecoder - " + Pdf417Decoder.VersionNumber + " \u00a9 2019 Uzi Granot. All rights reserved.";

                #if DEBUG
            // current directory
            string CurDir  = Environment.CurrentDirectory;
            string WorkDir = CurDir.Replace("bin\\Debug", "Work");
            if (WorkDir != CurDir && Directory.Exists(WorkDir))
            {
                Environment.CurrentDirectory = WorkDir;
            }

            // open trace file
            Pdf417Trace.Open("Pdf417VideoDecoderTrace.txt");
            Pdf417Trace.Write(Text);
                #endif

            // disable reset button
            ResetButton.Enabled   = false;
            GoToUriButton.Enabled = false;

            // get an array of web camera devices
            DsDevice[] CameraDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);

            // make sure at least one is available
            if (CameraDevices == null || CameraDevices.Length == 0)
            {
                MessageBox.Show("No video cameras in this computer");
                Close();
                return;
            }

            // select the first camera
            DsDevice CameraDevice = CameraDevices[0];

            // Device moniker
            IMoniker CameraMoniker = CameraDevice.Moniker;

            // get a list of frame sizes available
            FrameSize[] FrameSizes = Camera.GetFrameSizeList(CameraMoniker);

            // make sure there is at least one frame size
            if (FrameSizes == null || FrameSizes.Length == 0)
            {
                MessageBox.Show("No video cameras in this computer");
                Close();
                return;
            }

            // test if our frame size is available
            int Index;
            for (Index = 0; Index < FrameSizes.Length &&
                 (FrameSizes[Index].Width != FrameSize.Width || FrameSizes[Index].Height != FrameSize.Height); Index++)
            {
                ;
            }

            // select first frame size
            if (Index == FrameSizes.Length)
            {
                FrameSize = FrameSizes[0];
            }

            // Set selected camera to camera control with default frame size
            // Create camera object
            VideoCamera = new Camera(PreviewPanel, CameraMoniker, FrameSize);

            // create QR code decoder
            Decoder = new Pdf417Decoder();

            // resize window
            OnResize(sender, e);

            // create timer
            VideoDecoderTimer          = new Timer();
            VideoDecoderTimer.Interval = 200;
            VideoDecoderTimer.Tick    += VideoDecoderTimer_Tick;
            VideoDecoderTimer.Enabled  = true;
            return;
        }