removing submodule
Some checks failed
build lightwatch / build (push) Failing after 5m6s

This commit is contained in:
2023-09-03 01:14:34 -04:00
parent d539dc9119
commit ed18dd911a
190 changed files with 1174526 additions and 4 deletions

View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\RPiRgbLEDMatrix.csproj" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,40 @@
using RPiRgbLEDMatrix;
using System.Runtime.InteropServices;
using Color = RPiRgbLEDMatrix.Color;
Console.Write("GIF path: ");
var path = Console.ReadLine()!;
using var matrix = new RGBLedMatrix(32, 2, 1);
var canvas = matrix.CreateOffscreenCanvas();
Configuration.Default.PreferContiguousImageBuffers = true;
using var image = Image.Load<Rgb24>(path);
image.Mutate(o => o.Resize(canvas.Width, canvas.Height));
var running = true;
Console.CancelKeyPress += (s, e) =>
{
running = false;
e.Cancel = true; // don't terminate, we need to dispose
};
var frame = -1;
// preprocess frames to get delays and pixel buffers
var frames = image.Frames
.Select(f => (
Pixels: f.DangerousTryGetSinglePixelMemory(out var memory) ? memory : throw new("Could not get pixel buffer"),
Delay: f.Metadata.GetGifMetadata().FrameDelay * 10
)).ToArray();
// run until user presses Ctrl+C
while (running)
{
frame = (frame + 1) % frames.Length;
var data = MemoryMarshal.Cast<Rgb24, Color>(frames[frame].Pixels.Span);
canvas.SetPixels(0, 0, canvas.Width, canvas.Height, data);
matrix.SwapOnVsync(canvas);
Thread.Sleep(frames[frame].Delay);
}