From 175899a5390ac8696dd627566ac07b08a6cec8de Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Mon, 3 Apr 2023 10:40:53 -0700 Subject: [PATCH] add optimization notes --- build.zig | 4 ++++ src/main.zig | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/build.zig b/build.zig index 107dd60..c454d20 100644 --- a/build.zig +++ b/build.zig @@ -46,6 +46,10 @@ pub fn build(b: *std.build.Builder) !void { exe.addIncludePath("lib/i2cdriver"); exe.install(); + // TODO: I believe we can use runArtifact on a second + // exe with a different source file for font generation + // taking us to a series of 5 byte arrays for each + // character in a font. exe.step.dependOn(&AsciiPrintableStep.create(b, .{ .path = "src/images" }).step); // exe.step.dependOn((try fontGeneration(b, target))); const run_cmd = exe.run(); diff --git a/src/main.zig b/src/main.zig index e09b9d1..1c86b86 100644 --- a/src/main.zig +++ b/src/main.zig @@ -277,6 +277,12 @@ fn convertImage(alloc: std.mem.Allocator, filename: [:0]u8, pixels: *[WIDTH * HE if (filename.len > 0) { status = c.MagickReadImage(mw, filename); } else { + // TODO: if there is no background image AND + // we precompute monochrome bit patterns for our font + // we can completely avoid ImageMagick here. Even with + // a background we can do the conversion, then do our + // own text overlay after monochrome conversion. + // Faster and smaller binary (maybe multi-font support?) const blob = @embedFile("images/blank.bmp"); status = c.MagickReadImageBlob(mw, blob, blob.len); }