예제 #1
0
        private void ReadHeader()
        {
            uint code = 0;
            uint startCode = 0;

            AlignStreamData();

            code = ReadStreamData(22);

             
            
            startCode = (uint)(code & ~0x1F);

            if (startCode == 32)
            {
                if (((code & 0x1F) == 0x1F))
                {
                	if (ImageSlice == null)
                        {
                            ImageSlice = new ImageSlice(BlockCount);
                            PixelData = new ushort[Width * Height];
                            InternalImageSource = new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                            Rectangle = new Int32Rect(0, 0, Width, Height);
                        }
                    PictureComplete = true;
                }
                else
                {
                    if (SliceIndex++ == 0)
                    {
                        PictureFormat = (int)ReadStreamData(2);
                        Resolution = (int)ReadStreamData(3);
                        PictureType = (int)ReadStreamData(3);
                        QuantizerMode = (int)ReadStreamData(5);
                        FrameIndex = (int)ReadStreamData(32);

                        switch (PictureFormat)
                        {
                        	case 1: //(int)PictureFormats.Cif:
                                Width = CONST_WidthCif << Resolution - 1;
                                Height = CONST_HeightCif << Resolution - 1;
                                break;
                               case 2: //(int)PictureFormats.Vga:
                                Width = CONST_WidthVga << Resolution - 1;
                                Height = CONST_HeightVga << Resolution - 1;
                                break;
                        }

                        //We assume two bytes per pixel (RGB 565)
                        PixelRowSize = Width << 1;

                        SliceCount = Height >> 4;
                        BlockCount = Width >> 4;

                        if (ImageSlice == null)
                        {
                            ImageSlice = new ImageSlice(BlockCount);
                            PixelData = new ushort[Width * Height];
                            InternalImageSource = new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                            Rectangle = new Int32Rect(0, 0, Width, Height);
                        }
                        else
                        {
                            if (ImageSlice.MacroBlocks.Count != BlockCount)
                            {
                                ImageSlice = new ImageSlice(BlockCount);
                                PixelData = new ushort[Width * Height];
                                InternalImageSource = new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                                Rectangle = new Int32Rect(0, 0, Width, Height);
                            }
                        }
                    }
                    else
                    {
                        QuantizerMode = (int)ReadStreamData(5);
                    }
                }
            }
        }
예제 #2
0
 public VideoImage()
 {
     ImageStreams = new Stack<byte[]>();
     Width = CONST_WidthVga << Resolution - 1;
     Height = CONST_HeightVga << Resolution - 1;
     BlockCount = Width >> 4;
     ImageSlice = new ImageSlice(BlockCount);
      PixelData = new ushort[Width * Height];
                     InternalImageSource = new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                     Rectangle = new Int32Rect(0, 0, Width, Height);
 }