public LedMatrix(LedMatrixOptions options = null, string[] arguments = null) { options = options ?? new LedMatrixOptions(); var opt = new NativeLedMatrixOptions(options); try { var nativeArguments = arguments.ConvertToNativeArguments(options); _matrix = RpiRgbLedMatrix.led_matrix_create_from_options_const_argv(ref opt, nativeArguments.Length, nativeArguments); } finally { if (options.HardwareMapping != null) { opt.Free(ref opt.hardware_mapping); } if (options.LedRgbSequence != null) { opt.Free(ref opt.led_rgb_sequence); } if (options.PixelMapperConfig != null) { opt.Free(ref opt.pixel_mapper_config); } if (options.PanelType != null) { opt.Free(ref opt.panel_type); } } }
/// <summary> /// Initializes a new instance of a <see cref="BdfFont" />. /// </summary> /// <param name="bdfFontFile">A path to a bdf font file.</param> public BdfFont(string bdfFontFile) { if (String.IsNullOrEmpty(bdfFontFile)) { throw new ArgumentNullException(nameof(bdfFontFile)); } if (!File.Exists(bdfFontFile)) { // try local folder as an alternative var alternateFontPath = Path.Combine( Path.GetDirectoryName(GetType().Assembly.Location), Path.GetFileName(bdfFontFile) ); if (!File.Exists(alternateFontPath)) { throw new ArgumentException($"The provided file '{bdfFontFile}' needs to exist."); } bdfFontFile = alternateFontPath; } _font = RpiRgbLedMatrix.load_font(bdfFontFile); }
internal Canvas(IntPtr canvas) { if (canvas == null || canvas == IntPtr.Zero) { throw new ArgumentNullException(nameof(canvas)); } _canvas = canvas; RpiRgbLedMatrix.led_canvas_get_size(_canvas, out int width, out int height); Width = width; Height = height; }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { } RpiRgbLedMatrix.led_matrix_delete(_matrix); _matrix = IntPtr.Zero; disposedValue = true; } }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { } RpiRgbLedMatrix.delete_font(_font); _font = IntPtr.Zero; disposedValue = true; } }
public void DrawLine(int x0, int y0, int x1, int y1, Color color) { RpiRgbLedMatrix.draw_line(_canvas, x0, y0, x1, y1, color.Red, color.Green, color.Blue); }
public void DrawCircle(int x, int y, int radius, Color color) { RpiRgbLedMatrix.draw_circle(_canvas, x, y, radius, color.Red, color.Green, color.Blue); }
public void Clear() { RpiRgbLedMatrix.led_canvas_clear(_canvas); }
public void Fill(Color color) { RpiRgbLedMatrix.led_canvas_fill(_canvas, color.Red, color.Green, color.Blue); }
public void SetImage(int xOffset, int yOffset, byte[] imageBuffer, int bufferSizeBytes, int imageWidth, int imageHeight, bool isBgr) { RpiRgbLedMatrix.set_image(_canvas, xOffset, yOffset, imageBuffer, bufferSizeBytes, imageWidth, imageHeight, isBgr); }
public void SetPixel(int x, int y, Color color) { RpiRgbLedMatrix.led_canvas_set_pixel(_canvas, x, y, color.Red, color.Green, color.Blue); }
public Canvas SwapOnVsync(Canvas canvas) { canvas._canvas = RpiRgbLedMatrix.led_matrix_swap_on_vsync(_matrix, canvas._canvas); return(canvas); }
public Canvas GetCanvas() { var canvas = RpiRgbLedMatrix.led_matrix_get_canvas(_matrix); return(new Canvas(canvas)); }
public Canvas CreateOffscreenCanvas() { var canvas = RpiRgbLedMatrix.led_matrix_create_offscreen_canvas(_matrix); return(new Canvas(canvas)); }
internal int DrawText(IntPtr canvas, int x, int y, Color color, string text, int spacing = 0, bool vertical = false) { return((vertical) ? RpiRgbLedMatrix.vertical_draw_text(canvas, _font, x, y, color.Red, color.Green, color.Blue, text, spacing) : RpiRgbLedMatrix.draw_text(canvas, _font, x, y, color.Red, color.Green, color.Blue, text, spacing)); }