mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-03 19:33:07 +03:00
Accept float values for putdata() in Python 3.10
This commit is contained in:
parent
020308a7be
commit
e9294d890f
|
@ -47,6 +47,12 @@ def test_pypy_performance():
|
||||||
im.putdata(list(range(256)) * 256)
|
im.putdata(list(range(256)) * 256)
|
||||||
|
|
||||||
|
|
||||||
|
def test_mode_with_L_with_float():
|
||||||
|
im = Image.new("L", (1, 1), 0)
|
||||||
|
im.putdata([2.0])
|
||||||
|
assert im.getpixel((0, 0)) == 2
|
||||||
|
|
||||||
|
|
||||||
def test_mode_i():
|
def test_mode_i():
|
||||||
src = hopper("L")
|
src = hopper("L")
|
||||||
data = list(src.getdata())
|
data = list(src.getdata())
|
||||||
|
|
|
@ -1526,7 +1526,7 @@ _putdata(ImagingObject *self, PyObject *args) {
|
||||||
/* Clipped data */
|
/* Clipped data */
|
||||||
for (i = x = y = 0; i < n; i++) {
|
for (i = x = y = 0; i < n; i++) {
|
||||||
op = PySequence_Fast_GET_ITEM(seq, i);
|
op = PySequence_Fast_GET_ITEM(seq, i);
|
||||||
image->image8[y][x] = (UINT8)CLIP8(PyLong_AsLong(op));
|
image->image8[y][x] = (UINT8)CLIP8((int)PyFloat_AsDouble(op));
|
||||||
if (++x >= (int)image->xsize) {
|
if (++x >= (int)image->xsize) {
|
||||||
x = 0, y++;
|
x = 0, y++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user