mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-10-27 22:21:33 +03:00
Simplify code now that I;16* modes are the only IMAGING_TYPE_SPECIAL (#9263)
This commit is contained in:
commit
e36e67081a
|
|
@ -543,12 +543,7 @@ getpixel(Imaging im, ImagingAccess access, int x, int y) {
|
|||
case IMAGING_TYPE_FLOAT32:
|
||||
return PyFloat_FromDouble(pixel.f);
|
||||
case IMAGING_TYPE_SPECIAL:
|
||||
if (im->bands == 1) {
|
||||
return PyLong_FromLong(pixel.h);
|
||||
} else {
|
||||
return Py_BuildValue("BBB", pixel.b[0], pixel.b[1], pixel.b[2]);
|
||||
}
|
||||
break;
|
||||
return PyLong_FromLong(pixel.h);
|
||||
}
|
||||
|
||||
/* unknown type */
|
||||
|
|
@ -665,26 +660,10 @@ getink(PyObject *color, Imaging im, char *ink) {
|
|||
memcpy(ink, &ftmp, sizeof(ftmp));
|
||||
return ink;
|
||||
case IMAGING_TYPE_SPECIAL:
|
||||
if (isModeI16(im->mode)) {
|
||||
ink[0] = (UINT8)r;
|
||||
ink[1] = (UINT8)(r >> 8);
|
||||
ink[2] = ink[3] = 0;
|
||||
return ink;
|
||||
} else {
|
||||
if (rIsInt) {
|
||||
b = (UINT8)(r >> 16);
|
||||
g = (UINT8)(r >> 8);
|
||||
r = (UINT8)r;
|
||||
} else if (tupleSize != 3) {
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError,
|
||||
"color must be int, or tuple of one or three elements"
|
||||
);
|
||||
return NULL;
|
||||
} else if (!PyArg_ParseTuple(color, "iiL", &b, &g, &r)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
ink[0] = (UINT8)r;
|
||||
ink[1] = (UINT8)(r >> 8);
|
||||
ink[2] = ink[3] = 0;
|
||||
return ink;
|
||||
}
|
||||
|
||||
PyErr_SetString(PyExc_ValueError, wrong_mode);
|
||||
|
|
|
|||
|
|
@ -714,14 +714,7 @@ getfilter(Imaging im, int filterid) {
|
|||
case IMAGING_TYPE_UINT8:
|
||||
return nearest_filter8;
|
||||
case IMAGING_TYPE_SPECIAL:
|
||||
switch (im->pixelsize) {
|
||||
case 1:
|
||||
return nearest_filter8;
|
||||
case 2:
|
||||
return nearest_filter16;
|
||||
case 4:
|
||||
return nearest_filter32;
|
||||
}
|
||||
return nearest_filter16;
|
||||
}
|
||||
} else {
|
||||
return nearest_filter32;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user