mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-12 17:22:28 +03:00
Error handling has changed, methods return null on error
This commit is contained in:
parent
0043a22c23
commit
c592845bd4
|
@ -24,7 +24,7 @@ http://www.cazabon.com\n\
|
||||||
"
|
"
|
||||||
|
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "lcms.h"
|
#include "lcms2.h"
|
||||||
#include "Imaging.h"
|
#include "Imaging.h"
|
||||||
#include "py3.h"
|
#include "py3.h"
|
||||||
|
|
||||||
|
@ -37,11 +37,12 @@ http://www.cazabon.com\n\
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PYCMSVERSION "0.1.0 pil"
|
#define PYCMSVERSION "1.0.0 pil"
|
||||||
|
|
||||||
/* version history */
|
/* version history */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
1.0.0 pil Integrating littleCMS2
|
||||||
0.1.0 pil integration & refactoring
|
0.1.0 pil integration & refactoring
|
||||||
0.0.2 alpha: Minor updates, added interfaces to littleCMS features, Jan 6, 2003
|
0.0.2 alpha: Minor updates, added interfaces to littleCMS features, Jan 6, 2003
|
||||||
- fixed some memory holes in how transforms/profiles were created and passed back to Python
|
- fixed some memory holes in how transforms/profiles were created and passed back to Python
|
||||||
|
@ -107,8 +108,6 @@ cms_profile_open(PyObject* self, PyObject* args)
|
||||||
if (!PyArg_ParseTuple(args, "s:profile_open", &sProfile))
|
if (!PyArg_ParseTuple(args, "s:profile_open", &sProfile))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
hProfile = cmsOpenProfileFromFile(sProfile, "r");
|
hProfile = cmsOpenProfileFromFile(sProfile, "r");
|
||||||
if (!hProfile) {
|
if (!hProfile) {
|
||||||
PyErr_SetString(PyExc_IOError, "cannot open profile file");
|
PyErr_SetString(PyExc_IOError, "cannot open profile file");
|
||||||
|
@ -133,8 +132,6 @@ cms_profile_fromstring(PyObject* self, PyObject* args)
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
hProfile = cmsOpenProfileFromMem(pProfile, nProfile);
|
hProfile = cmsOpenProfileFromMem(pProfile, nProfile);
|
||||||
if (!hProfile) {
|
if (!hProfile) {
|
||||||
PyErr_SetString(PyExc_IOError, "cannot open profile from string");
|
PyErr_SetString(PyExc_IOError, "cannot open profile from string");
|
||||||
|
@ -273,8 +270,6 @@ _buildTransform(cmsHPROFILE hInputProfile, cmsHPROFILE hOutputProfile, char *sIn
|
||||||
{
|
{
|
||||||
cmsHTRANSFORM hTransform;
|
cmsHTRANSFORM hTransform;
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
||||||
/* create the transform */
|
/* create the transform */
|
||||||
|
@ -297,8 +292,6 @@ _buildProofTransform(cmsHPROFILE hInputProfile, cmsHPROFILE hOutputProfile, cmsH
|
||||||
{
|
{
|
||||||
cmsHTRANSFORM hTransform;
|
cmsHTRANSFORM hTransform;
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
|
||||||
/* create the transform */
|
/* create the transform */
|
||||||
|
@ -336,8 +329,6 @@ buildTransform(PyObject *self, PyObject *args) {
|
||||||
if (!PyArg_ParseTuple(args, "O!O!ss|ii:buildTransform", &CmsProfile_Type, &pInputProfile, &CmsProfile_Type, &pOutputProfile, &sInMode, &sOutMode, &iRenderingIntent, &cmsFLAGS))
|
if (!PyArg_ParseTuple(args, "O!O!ss|ii:buildTransform", &CmsProfile_Type, &pInputProfile, &CmsProfile_Type, &pOutputProfile, &sInMode, &sOutMode, &iRenderingIntent, &cmsFLAGS))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
transform = _buildTransform(pInputProfile->profile, pOutputProfile->profile, sInMode, sOutMode, iRenderingIntent, cmsFLAGS);
|
transform = _buildTransform(pInputProfile->profile, pOutputProfile->profile, sInMode, sOutMode, iRenderingIntent, cmsFLAGS);
|
||||||
|
|
||||||
if (!transform)
|
if (!transform)
|
||||||
|
@ -363,8 +354,6 @@ buildProofTransform(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "O!O!O!ss|iii:buildProofTransform", &CmsProfile_Type, &pInputProfile, &CmsProfile_Type, &pOutputProfile, &CmsProfile_Type, &pProofProfile, &sInMode, &sOutMode, &iRenderingIntent, &iProofIntent, &cmsFLAGS))
|
if (!PyArg_ParseTuple(args, "O!O!O!ss|iii:buildProofTransform", &CmsProfile_Type, &pInputProfile, &CmsProfile_Type, &pOutputProfile, &CmsProfile_Type, &pProofProfile, &sInMode, &sOutMode, &iRenderingIntent, &iProofIntent, &cmsFLAGS))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
transform = _buildProofTransform(pInputProfile->profile, pOutputProfile->profile, pProofProfile->profile, sInMode, sOutMode, iRenderingIntent, iProofIntent, cmsFLAGS);
|
transform = _buildProofTransform(pInputProfile->profile, pOutputProfile->profile, pProofProfile->profile, sInMode, sOutMode, iRenderingIntent, iProofIntent, cmsFLAGS);
|
||||||
|
|
||||||
if (!transform)
|
if (!transform)
|
||||||
|
@ -390,8 +379,6 @@ cms_transform_apply(CmsTransformObject *self, PyObject *args)
|
||||||
im = (Imaging) idIn;
|
im = (Imaging) idIn;
|
||||||
imOut = (Imaging) idOut;
|
imOut = (Imaging) idOut;
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
result = pyCMSdoTransform(im, imOut, self->transform);
|
result = pyCMSdoTransform(im, imOut, self->transform);
|
||||||
|
|
||||||
return Py_BuildValue("i", result);
|
return Py_BuildValue("i", result);
|
||||||
|
@ -412,8 +399,6 @@ createProfile(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "s|i:createProfile", &sColorSpace, &iColorTemp))
|
if (!PyArg_ParseTuple(args, "s|i:createProfile", &sColorSpace, &iColorTemp))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cmsErrorAction(LCMS_ERROR_IGNORE);
|
|
||||||
|
|
||||||
if (strcmp(sColorSpace, "LAB") == 0) {
|
if (strcmp(sColorSpace, "LAB") == 0) {
|
||||||
if (iColorTemp > 0) {
|
if (iColorTemp > 0) {
|
||||||
result = cmsWhitePointFromTemp(iColorTemp, whitePoint);
|
result = cmsWhitePointFromTemp(iColorTemp, whitePoint);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user