summaryrefslogtreecommitdiff
path: root/src/term/TerminalImages.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/term/TerminalImages.zig')
-rw-r--r--src/term/TerminalImages.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/term/TerminalImages.zig b/src/term/TerminalImages.zig
index 3847be4c..1420d9e3 100644
--- a/src/term/TerminalImages.zig
+++ b/src/term/TerminalImages.zig
@@ -10,13 +10,15 @@
const std = @import("std");
const plain = @import("plain");
const ghostty_vt = @import("ghostty-vt");
-const pardes = @import("../pardes.zig");
const zstbi = @import("zstbi");
const wuffs = @import("wuffs");
const TerminalImages = @This();
const gfx = ghostty_vt.kitty.graphics;
const PixelRect = plain.RectPx;
+/// Pixels one image may decode to (RGBA, 4 bytes each): checked from its
+/// header before it is decoded.
+const image_decode_pixels: usize = 64 * 1024 * 1024;
/// The bytes ghostty-vt may hold for one screen's images (it evicts the
/// oldest past this): a 4K picture in RGBA, with room for a second.
@@ -141,7 +143,7 @@ fn decodePng(gpa: std.mem.Allocator, bytes: []const u8) ghostty_vt.sys.DecodeErr
if (bytes.len < 24 or !std.mem.startsWith(u8, bytes, "\x89PNG\r\n\x1a\n") or !std.mem.eql(u8, bytes[12..16], "IHDR")) return error.InvalidData;
const w = std.mem.readInt(u32, bytes[16..20], .big);
const h = std.mem.readInt(u32, bytes[20..24], .big);
- if (@as(u64, w) * h > pardes.memory.limits.image_decode_pixels) return error.InvalidData;
+ if (@as(u64, w) * h > image_decode_pixels) return error.InvalidData;
const got = wuffs.png.decode(gpa, bytes) catch return error.InvalidData;
if (got.data.len != @as(usize, got.width) * got.height * 4) {
gpa.free(got.data);