Exemplo n.º 1
0
        void FillARGBColourBars(IDeckLinkVideoFrame theFrame)
        {
            IntPtr buffer;
            int    width, height;

            // UInt32[] bars = { 0xEAEAEAFF, 0x10EAEAFF, 0xEAEA10FF, 0xEA10EAFF, 0x10EA10FF, 0x1010EAFF , 0xEA1010FF, 0x101010FF };
            //   UInt32[] bars = { 0x101010FF , 0xEA1010FF,  0xEAEA10FF, 0xEA10EAFF, 0x10EA10FF, 0x10EAEAFF, 0x1010EAFF, 0xEAEAEAFF };//reversed
            UInt32[] bars = { 0xFF101010, 0x10FF1010, 0x1010FF10, 0x101010FF, 0x101010FF, 0x1010FF10, 0x10FF1010, 0xFF101010 };//PruhARGBBGRA

            int index = 0;

            theFrame.GetBytes(out buffer);
            width  = theFrame.GetWidth();
            height = theFrame.GetHeight();

            for (uint y = 0; y < height; y++)
            {
                for (uint x = 0; x < width; x++)
                {
                    // Write directly into unmanaged buffer
                    Marshal.WriteInt32(buffer, index * 4, (Int32)bars[(x * 8) / width]);
                    index++;
                }
            }
        }
Exemplo n.º 2
0
        private void VideoFrameArrived(object sender, DeckLinkVideoFrameArrivedEventArgs e)
        {
            checkBoxInputValid.Checked = !e.inputInvalid;

            if (e.inputInvalid)
            {
                if (++m_invalidFrameTimeout == kInputInvalidFrameTimeout)
                {
                    if (MessageBox.Show("Timeout waiting for valid input signal.", "Invalid frame timeout") == DialogResult.OK)
                    {
                        if (m_captureInvalidCancel != null)
                        {
                            m_captureInvalidCancel.Cancel();
                        }
                    }
                }
            }
            else if (++m_captureFrameIntervalCount == numericUpDownCaptureFrameInterval.Value)
            {
                IntPtr bgra32FrameBytes;
                String outputFileName = m_selectedFolder + "\\image_" + m_captureStillsCount.ToString("D4") + "." + comboBoxFileType.SelectedItem.ToString().ToLower();

                if (File.Exists(outputFileName))
                {
                    if (MessageBox.Show("File " + outputFileName + " already exists, stopping capture", "File Exists") == DialogResult.OK)
                    {
                        if (m_captureFileExists != null)
                        {
                            m_captureFileExists.Cancel();
                        }
                        return;
                    }
                }

                IDeckLinkVideoFrame bgra32Frame = m_frameConverter.ConvertFrame(e.videoFrame);
                bgra32Frame.GetBytes(out bgra32FrameBytes);

                using (Bitmap bgra32Bitmap = new Bitmap(bgra32Frame.GetWidth(), bgra32Frame.GetHeight(), bgra32Frame.GetRowBytes(), PixelFormat.Format32bppArgb, bgra32FrameBytes))
                {
                    bgra32Bitmap.Save(outputFileName, (ImageFormat)comboBoxFileType.SelectedItem);
                }

                m_captureFrameIntervalCount = 0;
                m_captureStillsCount++;

                if (m_captureCountdown != null)
                {
                    m_captureCountdown.Signal();
                }
            }
        }
Exemplo n.º 3
0
        void FillBlack(IDeckLinkVideoFrame theFrame)
        {
            IntPtr buffer;
            int    width, height;
            int    wordsRemaining;
            UInt32 black = 0x10801080;
            int    index = 0;

            theFrame.GetBytes(out buffer);
            width  = theFrame.GetWidth();
            height = theFrame.GetHeight();

            wordsRemaining = (width * 2 * height) / 4;

            while (wordsRemaining-- > 0)
            {
                Marshal.WriteInt32(buffer, index * 4, (Int32)black);
                index++;
            }
        }
Exemplo n.º 4
0
        void FillBlack(IDeckLinkVideoFrame theFrame)
        {
            IntPtr buffer;
            int    width, height;

            UInt32[] bars  = { 0x11111111, 0xAAAAAAAA, 0x11111111, 0xAAAAAAAA, 0x11111111, 0xAAAAAAAA, 0x11111111, 0xAAAAAAAA };
            int      index = 0;

            theFrame.GetBytes(out buffer);
            width  = theFrame.GetWidth();
            height = theFrame.GetHeight();

            for (uint y = 0; y < height; y++)
            {
                for (uint x = 0; x < width; x += 1)
                {
                    // Write directly into unmanaged buffer
                    Marshal.WriteInt32(buffer, index * 4, (Int32)bars[(x * 8) / width]);
                    index++;
                }
            }
        }
Exemplo n.º 5
0
        void FillColourBars(IDeckLinkVideoFrame theFrame)
        {
            IntPtr buffer;
            int    width, height;

            UInt32[] bars  = { 0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035, 0x6ADD6ACA, 0x51EF515A, 0x286D28EF, 0x10801080 };
            int      index = 0;

            theFrame.GetBytes(out buffer);
            width  = theFrame.GetWidth();
            height = theFrame.GetHeight();

            for (uint y = 0; y < height; y++)
            {
                for (uint x = 0; x < width; x += 2)
                {
                    // Write directly into unmanaged buffer
                    Marshal.WriteInt32(buffer, index * 4, (Int32)bars[(x * 8) / width]);
                    index++;
                }
            }
        }