diff options
Diffstat (limited to 'src/TerminalImages.zig')
| -rw-r--r-- | src/TerminalImages.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/TerminalImages.zig b/src/TerminalImages.zig index c352c2a4..f8fed78e 100644 --- a/src/TerminalImages.zig +++ b/src/TerminalImages.zig @@ -123,8 +123,9 @@ const max_dim: u32 = 1280; var started = false; /// Once at startup and exit, with what the resize allocates from. -pub fn start(io: std.Io, gpa: std.mem.Allocator) void { - zstbi.init(io, gpa); +pub fn start(gpa: std.mem.Allocator) void { + // Refused only when started twice with a resize still alive: PNGs then stay refused. + zstbi.init(gpa) catch return; started = true; } pub fn stop() void { @@ -149,7 +150,7 @@ fn decodePng(gpa: std.mem.Allocator, bytes: []const u8) ghostty_vt.sys.DecodeErr if (longest <= max_dim) return .{ .width = got.width, .height = got.height, .data = got.data }; defer gpa.free(got.data); const img: zstbi.Image = .{ .data = got.data, .width = got.width, .height = got.height, .num_components = 4, .bytes_per_component = 1, .bytes_per_row = got.width * 4, .is_hdr = false }; - var scaled = img.resize(@intCast(@max(1, @as(u64, got.width) * max_dim / longest)), @intCast(@max(1, @as(u64, got.height) * max_dim / longest))); + var scaled = img.resize(@intCast(@max(1, @as(u64, got.width) * max_dim / longest)), @intCast(@max(1, @as(u64, got.height) * max_dim / longest))) catch return error.InvalidData; defer scaled.deinit(); return .{ .width = scaled.width, .height = scaled.height, .data = gpa.dupe(u8, scaled.data) catch return error.InvalidData }; } |
