mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-15 06:07:33 +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()
|
im.load()
|
||||||
if imOut is None:
|
if imOut is None:
|
||||||
imOut = Image.new(self.output_mode, im.size, 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()
|
imOut.info["icc_profile"] = self.output_profile.tobytes()
|
||||||
return imOut
|
return imOut
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ class ImageCmsTransform(Image.ImagePointHandler):
|
||||||
if im.mode != self.output_mode:
|
if im.mode != self.output_mode:
|
||||||
msg = "mode mismatch"
|
msg = "mode mismatch"
|
||||||
raise ValueError(msg) # wrong output mode
|
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()
|
im.info["icc_profile"] = self.output_profile.tobytes()
|
||||||
return im
|
return im
|
||||||
|
|
||||||
|
|
|
@ -531,23 +531,26 @@ buildProofTransform(PyObject *self, PyObject *args) {
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
cms_transform_apply(CmsTransformObject *self, PyObject *args) {
|
cms_transform_apply(CmsTransformObject *self, PyObject *args) {
|
||||||
Py_ssize_t idIn;
|
PyObject *i0, *i1;
|
||||||
Py_ssize_t idOut;
|
|
||||||
Imaging im;
|
Imaging im;
|
||||||
Imaging imOut;
|
Imaging imOut;
|
||||||
|
|
||||||
int result;
|
if (!PyArg_ParseTuple(args, "OO:apply", &i0, &i1)) {
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "nn:apply", &idIn, &idOut)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
im = (Imaging)idIn;
|
if (!PyCapsule_IsValid(i0, IMAGING_MAGIC) ||
|
||||||
imOut = (Imaging)idOut;
|
!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