switch to new ranged for syntax

This commit is contained in:
Emil Lerch 2023-03-29 09:18:18 -07:00
parent 8ddc7bcdfa
commit a4973cb88a
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -292,24 +292,12 @@ fn convertImage(alloc: std.mem.Allocator, filename: [:0]u8, pixels: *[WIDTH * HE
if (status == c.MagickFalse) if (status == c.MagickFalse)
return error.CouldNotExportImage; return error.CouldNotExportImage;
// Getting a compile error here that feels wrong... for (0..WIDTH * HEIGHT) |i| {
// for (pixels) |*b| {
// switch (b) {
// 0x00 => b.* = 0xFF,
// 0xFF => b.* = 0x00,
// else => {},
// }
// }
// To reverse...
var i: usize = 0;
while (i < WIDTH * HEIGHT) {
switch (pixels[i]) { switch (pixels[i]) {
0x00 => pixels[i] = 0xFF, 0x00 => pixels[i] = 0xFF,
0xFF => pixels[i] = 0x00, 0xFF => pixels[i] = 0x00,
else => {}, else => {},
} }
i += 1;
} }
} }
// fn annotateImage(im: *c.Image, x: u32, y: u32, text: []const u8, fontSize: u32, color: []const u8 ) !void { // fn annotateImage(im: *c.Image, x: u32, y: u32, text: []const u8, fontSize: u32, color: []const u8 ) !void {