XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
UTF-8
using XFESystem.Branding;

if (args.Length != 1) throw new ArgumentException("Usage: BootAnimationPreview <new frame directory>");
string output = Path.GetFullPath(args[0]);
if (Directory.Exists(output)) throw new IOException("Preserve prior previews; choose a new directory.");
Directory.CreateDirectory(output);
const int width = 960, height = 540;
uint[] pixels = new uint[width * height];
for (int frame = 0; frame < 144; frame++)
{
    int milliseconds = frame * 1000 / 30;
    unsafe { fixed (uint* pointer = pixels) BootVisual.Draw(pointer, width, height, width, (ulong)milliseconds, milliseconds >= BootVisual.IntroMilliseconds); }
    using var stream = File.Create(Path.Combine(output, frame.ToString("D4") + ".ppm"));
    stream.Write(System.Text.Encoding.ASCII.GetBytes($"P6\n{width} {height}\n255\n"));
    byte[] row = new byte[width * 3];
    for (int y = 0; y < height; y++)
    {
        for (int x = 0; x < width; x++)
        { uint rgb = pixels[y * width + x]; row[x*3] = (byte)(rgb >> 16); row[x*3+1] = (byte)(rgb >> 8); row[x*3+2] = (byte)rgb; }
        stream.Write(row);
    }
}
Console.WriteLine(output);