public bool UpdateOptions(LedMatrixOptions options) { GCHandle h = GCHandle.Alloc(options, GCHandleType.Pinned); try { return(NativeMethods.led_matrix_update_options(this.handle, h.AddrOfPinnedObject())); } finally { h.Free(); } }
private static IntPtr CreateLedMatrix(LedMatrixOptions options) { GCHandle h = GCHandle.Alloc(options, GCHandleType.Pinned); try { IntPtr argv; IntPtr ptr = NativeMethods.led_matrix_create_from_options(h.AddrOfPinnedObject(), IntPtr.Zero, out argv); if (ptr == IntPtr.Zero) { throw new OutOfMemoryException("Can't create led matrix"); } return(ptr); } finally { h.Free(); } }
public LedMatrix(LedMatrixOptions options) : base(CreateLedMatrix(options), true) { this.m_updateLatch = new SemaphoreSlim(1); this.m_canvas = NativeMethods.led_matrix_create_offscreen_canvas(this.handle); NativeMethods.led_canvas_get_size(this.m_canvas, out this.m_canvasWidth, out this.m_canvasHeight); }