Skip to content

Commit 5a9cba5

Browse files
author
Adrià Arrufat
committed
Image.integralImage: only round if T is integer
1 parent 6fb2956 commit 5a9cba5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/image.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@ pub fn Image(comptime T: type) type {
271271
const pos22 = r2_offset + c2;
272272
const area: f32 = @floatFromInt((r2 - r1) * (c2 - c1));
273273
const sum = integral.data[pos22] - integral.data[pos21] - integral.data[pos12] + integral.data[pos11];
274-
blurred.data[pos] = as(T, @round(sum / area));
274+
blurred.data[pos] = switch (@typeInfo(T)) {
275+
.Int, .ComptimeInt => as(T, @round(sum / area)),
276+
.Float, .ComptimeFloat => as(T, sum / area),
277+
};
275278
pos += 1;
276279
rem -= 1;
277280
}

0 commit comments

Comments
 (0)