mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 09:14:27 +03:00
send a bytes object into the c layer instead of a bytearray, which is unimplemented in pypy
This commit is contained in:
parent
cf56ccc828
commit
eda4864b62
|
@ -195,7 +195,7 @@ class MorphOp:
|
||||||
raise Exception('No operator loaded')
|
raise Exception('No operator loaded')
|
||||||
|
|
||||||
outimage = Image.new(image.mode, image.size, None)
|
outimage = Image.new(image.mode, image.size, None)
|
||||||
count = _imagingmorph.apply(self.lut, image.im.id, outimage.im.id)
|
count = _imagingmorph.apply(bytes(self.lut), image.im.id, outimage.im.id)
|
||||||
return count, outimage
|
return count, outimage
|
||||||
|
|
||||||
def match(self, image):
|
def match(self, image):
|
||||||
|
@ -205,7 +205,7 @@ class MorphOp:
|
||||||
if self.lut is None:
|
if self.lut is None:
|
||||||
raise Exception('No operator loaded')
|
raise Exception('No operator loaded')
|
||||||
|
|
||||||
return _imagingmorph.match(self.lut, image.im.id)
|
return _imagingmorph.match(bytes(self.lut), image.im.id)
|
||||||
|
|
||||||
def get_on_pixels(self, image):
|
def get_on_pixels(self, image):
|
||||||
"""Get a list of all turned on pixels in a binary image
|
"""Get a list of all turned on pixels in a binary image
|
||||||
|
|
|
@ -45,19 +45,19 @@ apply(PyObject *self, PyObject* args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PyByteArray_Check(py_lut)) {
|
if (!PyBytes_Check(py_lut)) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a byte array");
|
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a bytes object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lut_len = PyByteArray_Size(py_lut);
|
lut_len = PyBytes_Size(py_lut);
|
||||||
|
|
||||||
if (lut_len < LUT_SIZE) {
|
if (lut_len < LUT_SIZE) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size");
|
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lut = PyByteArray_AsString(py_lut);
|
lut = PyBytes_AsString(py_lut);
|
||||||
|
|
||||||
imgin = (Imaging) i0;
|
imgin = (Imaging) i0;
|
||||||
imgout = (Imaging) i1;
|
imgout = (Imaging) i1;
|
||||||
|
@ -152,19 +152,19 @@ match(PyObject *self, PyObject* args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PyByteArray_Check(py_lut)) {
|
if (!PyBytes_Check(py_lut)) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a byte array");
|
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT is not a bytes object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lut_len = PyByteArray_Size(py_lut);
|
lut_len = PyBytes_Size(py_lut);
|
||||||
|
|
||||||
if (lut_len < LUT_SIZE) {
|
if (lut_len < LUT_SIZE) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size");
|
PyErr_SetString(PyExc_RuntimeError, "The morphology LUT has the wrong size");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
lut = PyByteArray_AsString(py_lut);
|
lut = PyBytes_AsString(py_lut);
|
||||||
imgin = (Imaging) i0;
|
imgin = (Imaging) i0;
|
||||||
|
|
||||||
if (imgin->type != IMAGING_TYPE_UINT8 &&
|
if (imgin->type != IMAGING_TYPE_UINT8 &&
|
||||||
|
|
Loading…
Reference in New Issue
Block a user