mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-14 01:04:45 +03:00
Merge d1c852a13b
into 555544c5cf
This commit is contained in:
commit
1ef813367b
37
_imaging.c
37
_imaging.c
|
@ -471,29 +471,29 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
|
||||||
static char*
|
static char*
|
||||||
getink(PyObject* color, Imaging im, char* ink)
|
getink(PyObject* color, Imaging im, char* ink)
|
||||||
{
|
{
|
||||||
int r, g, b, a;
|
int r = -1;
|
||||||
|
int g, b, a;
|
||||||
double f;
|
double f;
|
||||||
|
|
||||||
/* fill ink buffer (four bytes) with something that can
|
/* fill ink buffer (four bytes) with something that can
|
||||||
be cast to either UINT8 or INT32 */
|
be cast to either UINT8 or INT32 */
|
||||||
|
|
||||||
int rIsInt = 1;
|
int rIsInt = 0;
|
||||||
if (im->type == IMAGING_TYPE_UINT8 ||
|
if (im->type == IMAGING_TYPE_UINT8 ||
|
||||||
im->type == IMAGING_TYPE_INT32 ||
|
im->type == IMAGING_TYPE_INT32 ||
|
||||||
im->type == IMAGING_TYPE_SPECIAL) {
|
im->type == IMAGING_TYPE_SPECIAL) {
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
|
||||||
if (PyLong_Check(color)) {
|
if (PyLong_Check(color)) {
|
||||||
r = (int) PyLong_AsLong(color);
|
r = (int) PyLong_AsLong(color);
|
||||||
#else
|
if (!(r == -1 && PyErr_Occurred()))
|
||||||
if (PyInt_Check(color) || PyLong_Check(color)) {
|
rIsInt = 1;
|
||||||
if (PyInt_Check(color))
|
}
|
||||||
r = PyInt_AS_LONG(color);
|
#if PY_VERSION_HEX < 0x03000000
|
||||||
else
|
else if (PyInt_Check(color)) {
|
||||||
r = (int) PyLong_AsLong(color);
|
r = PyInt_AS_LONG(color);
|
||||||
#endif
|
if (!(r == -1 && PyErr_Occurred()))
|
||||||
|
rIsInt = 1;
|
||||||
}
|
}
|
||||||
if (r == -1 && PyErr_Occurred())
|
#endif
|
||||||
rIsInt = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (im->type) {
|
switch (im->type) {
|
||||||
|
@ -507,17 +507,7 @@ getink(PyObject* color, Imaging im, char* ink)
|
||||||
ink[1] = ink[2] = ink[3] = 0;
|
ink[1] = ink[2] = ink[3] = 0;
|
||||||
} else {
|
} else {
|
||||||
a = 255;
|
a = 255;
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
if (rIsInt) {
|
||||||
if (PyLong_Check(color)) {
|
|
||||||
r = (int) PyLong_AsLong(color);
|
|
||||||
#else
|
|
||||||
if (PyInt_Check(color) || PyLong_Check(color)) {
|
|
||||||
if (PyInt_Check(color))
|
|
||||||
r = PyInt_AS_LONG(color);
|
|
||||||
else
|
|
||||||
r = (int) PyLong_AsLong(color);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* compatibility: ABGR */
|
/* compatibility: ABGR */
|
||||||
a = (UINT8) (r >> 24);
|
a = (UINT8) (r >> 24);
|
||||||
b = (UINT8) (r >> 16);
|
b = (UINT8) (r >> 16);
|
||||||
|
@ -3596,4 +3586,3 @@ init_imaging(void)
|
||||||
setup_module(m);
|
setup_module(m);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user