Skip to content

Commit 2364037

Browse files
committed
Fix casts that apply to whole expression.
No need to cast the int before dividing, because the divisor is a double. It is necessary to cast the entire expression though, since the storage variable is only a float.
1 parent 89a3c7f commit 2364037

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/_png.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,12 @@ static PyObject *_read_png(PyObject *filein, bool float_result)
599599
if (bit_depth == 16) {
600600
png_uint_16 *ptr = &reinterpret_cast<png_uint_16 *>(row)[x * dimensions[2]];
601601
for (png_uint_32 p = 0; p < (png_uint_32)dimensions[2]; p++) {
602-
A(y, x, p) = (float)(ptr[p]) / max_value;
602+
A(y, x, p) = (float)(ptr[p] / max_value);
603603
}
604604
} else {
605605
png_byte *ptr = &(row[x * dimensions[2]]);
606606
for (png_uint_32 p = 0; p < (png_uint_32)dimensions[2]; p++) {
607-
A(y, x, p) = (float)(ptr[p]) / max_value;
607+
A(y, x, p) = (float)(ptr[p] / max_value);
608608
}
609609
}
610610
}

0 commit comments

Comments
 (0)