mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Use PyCapsule in _imagingcms
This commit is contained in:
parent
fe002a7260
commit
56bc6a1a71
|
@ -352,7 +352,7 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
|||
im.load()
|
||||
if imOut is None:
|
||||
imOut = Image.new(self.output_mode, im.size, None)
|
||||
self.transform.apply(im.im.id, imOut.im.id)
|
||||
self.transform.apply(im.im.ptr, imOut.im.ptr)
|
||||
imOut.info["icc_profile"] = self.output_profile.tobytes()
|
||||
return imOut
|
||||
|
||||
|
@ -361,7 +361,7 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
|||
if im.mode != self.output_mode:
|
||||
msg = "mode mismatch"
|
||||
raise ValueError(msg) # wrong output mode
|
||||
self.transform.apply(im.im.id, im.im.id)
|
||||
self.transform.apply(im.im.ptr, im.im.ptr)
|
||||
im.info["icc_profile"] = self.output_profile.tobytes()
|
||||
return im
|
||||
|
||||
|
|
|
@ -531,23 +531,26 @@ buildProofTransform(PyObject *self, PyObject *args) {
|
|||
|
||||
static PyObject *
|
||||
cms_transform_apply(CmsTransformObject *self, PyObject *args) {
|
||||
Py_ssize_t idIn;
|
||||
Py_ssize_t idOut;
|
||||
PyObject *i0, *i1;
|
||||
Imaging im;
|
||||
Imaging imOut;
|
||||
|
||||
int result;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "nn:apply", &idIn, &idOut)) {
|
||||
if (!PyArg_ParseTuple(args, "OO:apply", &i0, &i1)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
im = (Imaging)idIn;
|
||||
imOut = (Imaging)idOut;
|
||||
if (!PyCapsule_IsValid(i0, IMAGING_MAGIC) ||
|
||||
!PyCapsule_IsValid(i1, IMAGING_MAGIC)) {
|
||||
PyErr_Format(
|
||||
PyExc_TypeError, "Expected PyCapsule with '%s' name.", IMAGING_MAGIC
|
||||
);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = pyCMSdoTransform(im, imOut, self->transform);
|
||||
im = (Imaging)PyCapsule_GetPointer(i0, IMAGING_MAGIC);
|
||||
imOut = (Imaging)PyCapsule_GetPointer(i1, IMAGING_MAGIC);
|
||||
|
||||
return Py_BuildValue("i", result);
|
||||
return Py_BuildValue("i", pyCMSdoTransform(im, imOut, self->transform));
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue
Block a user