diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:29:32 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:01:28 -0300 |
| commit | 42694963a3b55398aac068820d00cd710685e4fb (patch) | |
| tree | 40b589573502695e2167d77f7585d85f43c76135 /src/image.zig | |
| parent | d093e439614d325573e771e7b9e24ea95c284104 (diff) | |
| download | pardes-42694963a3b55398aac068820d00cd710685e4fb.tar.gz pardes-42694963a3b55398aac068820d00cd710685e4fb.zip | |
image: nativeGeometry's contain is containGeometry, where it repeated it line for line
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/image.zig')
| -rw-r--r-- | src/image.zig | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/image.zig b/src/image.zig index 9163730d..fe515073 100644 --- a/src/image.zig +++ b/src/image.zig @@ -603,32 +603,14 @@ pub fn nativeGeometry( return switch (fit) { .width => fitWidth(src_w, src_h, body_pixel_w, body_pixel_h, pan_y), .height => fitHeight(src_w, src_h, body_pixel_w, body_pixel_h, pan_x), - .contain => blk: { - if (src_w <= body_pixel_w and src_h <= body_pixel_h) break :blk .{ - .src = .{ .w = src_w, .h = src_h }, - .dst = .{ .w = src_w, .h = src_h }, - }; - - // Compare scale ratios without floating point. The tighter bound - // is exact; the other is rounded inward. Contain intentionally - // ignores pan and keeps the historical top-left placement. - const dst: PixelRect = if (@as(u64, body_pixel_w) * src_h <= @as(u64, body_pixel_h) * src_w) - .{ - .w = body_pixel_w, - .h = @intCast(@max(1, @as(u64, src_h) * body_pixel_w / src_w)), - } - else - .{ - .w = @intCast(@max(1, @as(u64, src_w) * body_pixel_h / src_h)), - .h = body_pixel_h, - }; - break :blk .{ .src = .{ .w = src_w, .h = src_h }, .dst = dst }; - }, + // Pan is not contain's: it keeps the top-left placement. + .contain => containGeometry(iw, ih, body_pixel_w, body_pixel_h), }; } -/// The ordinary image-pane policy, separate from the PDF-only fit/pan -/// machinery so feature-off backends retain their original contain-only path. +/// The ordinary image-pane policy: shrunk only when it must be, at the top +/// left. The scale ratios are compared without floating point: the tighter +/// bound is exact, the other rounded inward. pub fn containGeometry(iw: usize, ih: usize, max_w: u32, max_h: u32) ?NativeGeometry { if (iw == 0 or ih == 0 or max_w == 0 or max_h == 0 or iw > std.math.maxInt(u32) or ih > std.math.maxInt(u32)) return null; |
