コード例 #1
0
        private void DisplayVideoFrameFromFile(string inputFileName)
        {
            BitmapData playbackBitmapData = null;
            Bitmap     playbackBitmap     = new Bitmap(inputFileName);

            try
            {
                var rect = new Rectangle(0, 0, playbackBitmap.Width, playbackBitmap.Height);

                // If in case storage is not 32bpp, then perform pixel format conversion
                if ((playbackBitmap.PixelFormat != PixelFormat.Format32bppArgb) && (playbackBitmap.PixelFormat != PixelFormat.Format32bppRgb))
                {
                    playbackBitmap = playbackBitmap.Clone(rect, PixelFormat.Format32bppArgb);
                }
                playbackBitmapData = playbackBitmap.LockBits(rect, ImageLockMode.ReadOnly, playbackBitmap.PixelFormat);

                // Create BGRA32 video frame based on bitmap data
                var playbackFrame = new Bgra32VideoFrame(playbackBitmap.Width, playbackBitmap.Height, _BMDFrameFlags.bmdFrameFlagDefault, playbackBitmapData.Scan0);
                m_selectedPlaybackDevice.DisplayVideoFrame((IDeckLinkVideoFrame)playbackFrame);
            }
            finally
            {
                if (playbackBitmap != null)
                {
                    playbackBitmap.UnlockBits(playbackBitmapData);
                    playbackBitmap.Dispose();
                }
            }
        }
コード例 #2
0
        public IDeckLinkVideoFrame ConvertFrame(IDeckLinkVideoFrame srcFrame)
        {
            IDeckLinkVideoFrame dstFrame;

            // Check whether srcFrame is already bmdFormat8BitBGRA
            if (srcFrame.GetPixelFormat() == _BMDPixelFormat.bmdFormat8BitBGRA)
            {
                dstFrame = srcFrame;
            }

            else
            {
                dstFrame = new Bgra32VideoFrame(srcFrame.GetWidth(), srcFrame.GetHeight(), srcFrame.GetFlags()) as IDeckLinkVideoFrame;
                m_deckLinkConversion.ConvertFrame(srcFrame, dstFrame);
            }

            return(dstFrame);
        }