Ejemplo n.º 1
0
        private void DrawImage(VideoFrameType type)
        {
            Stream       str    = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(str);

            // LITTLE ENDIAN!!
            writer.Write(new byte[] { 0x42, 0x4D });
            writer.Write((int)(type.managedData.Length + 0x36));
            writer.Write((int)0);
            writer.Write((int)0x36);
            writer.Write((int)40);
            writer.Write((int)type.width);
            writer.Write((int)type.height);
            writer.Write((short)1);
            writer.Write((short)24);
            writer.Write((int)0);
            writer.Write((int)type.managedData.Length);
            writer.Write((int)3780);
            writer.Write((int)3780);
            writer.Write((int)0);
            writer.Write((int)0);
            for (int y = type.height - 1; y >= 0; y--)
            {
                writer.Write(type.managedData, y * type.linesize, type.width * 3);
            }
            writer.Flush();
            writer.Seek(0, SeekOrigin.Begin);
            Bitmap bitmap = new Bitmap(str);

            graph.DrawImage(bitmap, 0, 0, panelShow.Width, panelShow.Height);
            bitmap.Dispose();
            writer.Close();
        }
Ejemplo n.º 2
0
        VideoPacket ConvertVideoPacket(byte[] data)
        {
            long           timestamp   = BitConverter.ToInt64(data, 0);
            uint           framenumber = BitConverter.ToUInt32(data, 8);
            ushort         height      = BitConverter.ToUInt16(data, 8 + 4);
            ushort         width       = BitConverter.ToUInt16(data, 8 + 4 + 2);
            VideoFrameType ft          = (VideoFrameType)BitConverter.ToInt32(data, 8 + 4 + 2 + 2);

            var viddata = new byte[data.Length - (8 + 4 + 2 + 2 + 4)];

            Array.Copy(data, 8 + 4 + 2 + 2 + 4, viddata, 0, viddata.Length);


            var packet = new VideoPacket
            {
                Timestamp   = timestamp,
                FrameNumber = framenumber,
                Height      = height,
                Width       = width,
                FrameType   = ft,
                Data        = viddata
            };

            return(packet);
        }