Skip to content

Commit

Permalink
image: fix slice in image view
Browse files Browse the repository at this point in the history
  • Loading branch information
arrufat committed Dec 10, 2024
1 parent 4d77430 commit ed5ce20
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/image.zig
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn Image(comptime T: type) type {
return .{
.rows = rect.height(),
.cols = rect.width(),
.data = self.data[rect.t * self.stride + rect.l .. rect.b * self.stride + rect.b],
.data = self.data[rect.t * self.stride + rect.l .. rect.b * self.stride + rect.r + 1],
.stride = self.cols,
};
}
Expand Down Expand Up @@ -297,6 +297,7 @@ pub fn Image(comptime T: type) type {
const r2_offset = r2 * self.cols;
const r2_r1 = r2 - r1;
if (r1 >= radius and r2 <= self.rows - 1 - radius and
self.cols >= 1 + radius + simd_len and
c >= radius and c <= self.cols - 1 - radius - simd_len and
rem >= simd_len)
{
Expand Down

0 comments on commit ed5ce20

Please sign in to comment.