Skip to content

Commit

Permalink
image: allow creating views of views
Browse files Browse the repository at this point in the history
  • Loading branch information
arrufat committed Dec 9, 2024
1 parent 0279279 commit ffac3ad
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/image.zig
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn Image(comptime T: type) type {
return .{
.rows = rect.height(),
.cols = rect.width(),
.data = self.data[rect.t * self.cols + rect.l ..],
.data = self.data[rect.t * self.stride + rect.l ..],
.stride = self.cols,
};
}
Expand Down Expand Up @@ -547,10 +547,9 @@ test "integral image struct" {
try expectEqual(image.data.len, integral.data.len);
for (0..image.rows) |r| {
for (0..image.cols) |c| {
const pos = r * image.cols + c;
const area_at_pos: f32 = @floatFromInt((r + 1) * (c + 1));
for (0..4) |i| {
try expectEqual(area_at_pos, integral.data[pos][i]);
try expectEqual(area_at_pos, integral.at(r, c)[i]);
}
}
}
Expand Down

0 comments on commit ffac3ad

Please sign in to comment.