private unsafe int OnFormatCallback(void **opaque, char *chroma, int *width, int *height, int *pitches, int *lines) { IntPtr pChroma = new IntPtr(chroma); string chromaStr = Marshal.PtrToStringAnsi(pChroma); ChromaType type = chromaStr.TryParseChromaType(); m_format = new BitmapFormat(*width, *height, type); if (m_formatSetupCB != null) { m_format = m_formatSetupCB(m_format); } Marshal.Copy(m_format.Chroma.ToUtf8(), 0, pChroma, 4); *width = m_format.Width; *height = m_format.Height; for (int i = 0; i < m_format.Planes; i++) { pitches[i] = m_format.Pitches[i]; lines[i] = m_format.Lines[i]; } m_pixelData = new PlanarPixelData(m_format.PlaneSizes); return(m_format.Planes); }
/// <summary> /// Initializes new instance of BitmapFormat class /// </summary> /// <param name="width">The width of the bitmap in pixels</param> /// <param name="height">The height of the bitmap in pixels</param> /// <param name="chroma">Chroma type of the bitmap</param> public BitmapFormat(int width, int height, ChromaType chroma) { m_width = width; m_height = height; m_chroma = chroma; Init(); Pitch = m_width * m_bpp; ImageSize = Pitch * height; Chroma = m_chroma.ToString(); }
public VideoDisplayContext(int width, int height, ChromaType chroma) { ChromaType = chroma; PixelFormat = chroma.GetPixelFormat(); IsAspectRatioChecked = false; Size = width * height * PixelFormat.BitsPerPixel / 8; DisplayWidth = Width = width; DisplayHeight = Height = height; Stride = width * PixelFormat.BitsPerPixel / 8; FileMapping = Win32Api.CreateFileMapping(new IntPtr(-1), IntPtr.Zero, PageAccess.ReadWrite, 0, Size, null); MapView = Win32Api.MapViewOfFile(FileMapping, FileMapAccess.AllAccess, 0, 0, (uint)Size); Image = (InteropBitmap) Imaging.CreateBitmapSourceFromMemorySection(FileMapping, Width, Height, PixelFormat, Stride, 0); }
public VideoDisplayContext(int width, int height, ChromaType chroma) { ChromaType = chroma; PixelFormat = chroma.GetPixelFormat(); IsAspectRatioChecked = false; Size = width*height*PixelFormat.BitsPerPixel/8; DisplayWidth = Width = width; DisplayHeight = Height = height; Stride = width*PixelFormat.BitsPerPixel/8; FileMapping = Win32Api.CreateFileMapping(new IntPtr(-1), IntPtr.Zero, PageAccess.ReadWrite, 0, Size, null); MapView = Win32Api.MapViewOfFile(FileMapping, FileMapAccess.AllAccess, 0, 0, (uint) Size); Image = (InteropBitmap) Imaging.CreateBitmapSourceFromMemorySection(FileMapping, Width, Height, PixelFormat, Stride, 0); }
/// <summary> /// Initializes new instance of BitmapFormat class /// </summary> /// <param name="width">The width of the bitmap in pixels</param> /// <param name="height">The height of the bitmap in pixels</param> /// <param name="chroma">Chroma type of the bitmap</param> public BitmapFormat(int width, int height, ChromaType chroma) { Width = width; Height = height; m_chroma = chroma; Planes = 1; Init(); Chroma = m_chroma.ToString(); if (IsRGB || !IsPlanarFormat) { m_sizes[0] = Pitch = Width * BitsPerPixel / 8; ImageSize = Pitch * Height; } }
private static PixelAlignmentType GetYuvType(ChromaType chromaType) { switch (chromaType) { case ChromaType.YV12: return PixelAlignmentType.YV12; case ChromaType.I420: return PixelAlignmentType.I420; case ChromaType.NV12: return PixelAlignmentType.NV12; case ChromaType.YUY2: return PixelAlignmentType.YUY2; case ChromaType.UYVY: return PixelAlignmentType.UYVY; default: throw new ArgumentException("Invalid parameter " + chromaType.ToString()); } }
/// <summary> /// Initializes new instance of BitmapFormat class /// </summary> /// <param name="width">The width of the bitmap in pixels</param> /// <param name="height">The height of the bitmap in pixels</param> /// <param name="chroma">Chroma type of the bitmap</param> public BitmapFormat(int width, int height, ChromaType chroma) { Width = width; Height = height; ChromaType = chroma; Planes = 1; PlaneSizes = new int[3]; Init(); Chroma = ChromaType.ToString(); if (IsRGB) { Pitch = Width * BitsPerPixel / 8; PlaneSizes[0] = ImageSize = Pitch * Height; Pitches = new int[1] { Pitch }; Lines = new int[1] { Height }; } }
public static PixelFormat GetPixelFormat(this ChromaType chroma) { switch (chroma) { case ChromaType.RV15: return(PixelFormats.Bgr555); case ChromaType.RV16: return(PixelFormats.Bgr565); case ChromaType.RV24: return(PixelFormats.Bgr24); case ChromaType.RV32: return(PixelFormats.Bgr32); case ChromaType.RGBA: return(PixelFormats.Bgra32); default: throw new NotSupportedException(String.Format("Not support pixel format: {0}", chroma)); } }
public VideoDisplayContext(double width, double height, ChromaType chroma) : this((int)width, (int)height, chroma) { }
public VideoDisplayContext(uint width, uint height, ChromaType chroma) : this((int)width, (int)height, chroma) { }
internal VideoFormatChangingEventArgs(uint width, uint height, ChromaType chromaType) { Width = width; Height = height; ChromaType = chromaType; }