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; if (!Enum.TryParse <ChromaType>(chromaStr, out type)) { throw new ArgumentException("Unsupported chroma type " + chromaStr); } 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); }
public void SetFormat(BitmapFormat format) { m_format = format; LibVlcMethods.libvlc_video_set_format(m_hMediaPlayer, m_format.Chroma.ToUtf8(), m_format.Width, m_format.Height, m_format.Pitch); m_pBuffer = MemoryHeap.Alloc(m_format.ImageSize); m_pixelData = new PixelData(m_format.ImageSize); m_pixelDataPtr = GCHandle.Alloc(m_pixelData, GCHandleType.Pinned); LibVlcMethods.libvlc_video_set_callbacks(m_hMediaPlayer, pLockCallback, pUnlockCallback, pDisplayCallback, m_pixelDataPtr.AddrOfPinnedObject()); }