Skip to content

Commit

Permalink
image: assert some usages of views
Browse files Browse the repository at this point in the history
  • Loading branch information
arrufat committed Dec 26, 2024
1 parent faee868 commit 54e5e89
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 @@ -49,6 +49,7 @@ pub fn Image(comptime T: type) type {
/// Returns the image data reinterpreted as a slice of bytes
pub fn asBytes(self: Self) []u8 {
assert(self.rows * self.cols == self.data.len);
assert(!self.isView());
return @as([*]u8, @ptrCast(@alignCast(self.data.ptr)))[0 .. self.data.len * @sizeOf(T)];
}

Expand All @@ -74,7 +75,7 @@ pub fn Image(comptime T: type) type {
/// Returns true if and only if self and other have the same number of rows, columns and
/// data size.
pub fn hasSameShape(self: Self, other: anytype) bool {
return self.rows == other.rows and self.cols == other.cols and self.data.len == other.data.len;
return self.rows == other.rows and self.cols == other.cols;
}

/// Returns the bounding rectangle for the current image.
Expand Down

0 comments on commit 54e5e89

Please sign in to comment.