diff --git a/src/_imaging.c b/src/_imaging.c index ecdaa51c429..2daf84b3c97 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -565,7 +565,7 @@ getpixel(Imaging im, ImagingAccess access, int x, int y) { return PyLong_FromLong(pixel.i); case IMAGING_TYPE_FLOAT32: return PyFloat_FromDouble(pixel.f); - case IMAGING_TYPE_SPECIAL: + case IMAGING_TYPE_I16: return PyLong_FromLong(pixel.h); } @@ -594,7 +594,7 @@ getink(PyObject *color, Imaging im, char *ink) { color = PyTuple_GetItem(color, 0); } if (im->type == IMAGING_TYPE_UINT8 || im->type == IMAGING_TYPE_INT32 || - im->type == IMAGING_TYPE_SPECIAL) { + im->type == IMAGING_TYPE_I16) { if (PyLong_Check(color)) { r = PyLong_AsLongLong(color); if (r == -1 && PyErr_Occurred()) { @@ -682,7 +682,7 @@ getink(PyObject *color, Imaging im, char *ink) { ftmp = f; memcpy(ink, &ftmp, sizeof(ftmp)); return ink; - case IMAGING_TYPE_SPECIAL: + case IMAGING_TYPE_I16: ink[0] = (UINT8)r; ink[1] = (UINT8)(r >> 8); ink[2] = ink[3] = 0; @@ -1671,7 +1671,7 @@ _putdata(ImagingObject *self, PyObject *args) { } double value; int bigendian = 0; - if (image->type == IMAGING_TYPE_SPECIAL) { + if (image->type == IMAGING_TYPE_I16) { // I;16* if ( image->mode == IMAGING_MODE_I_16B @@ -1687,7 +1687,7 @@ _putdata(ImagingObject *self, PyObject *args) { if (scale != 1.0 || offset != 0.0) { value = value * scale + offset; } - if (image->type == IMAGING_TYPE_SPECIAL) { + if (image->type == IMAGING_TYPE_I16) { image->image8[y][x * 2 + (bigendian ? 1 : 0)] = CLIP8((int)value % 256); image->image8[y][x * 2 + (bigendian ? 0 : 1)] = @@ -2358,7 +2358,7 @@ _getextrema(ImagingObject *self, PyObject *args) { return Py_BuildValue("ii", extrema.i[0], extrema.i[1]); case IMAGING_TYPE_FLOAT32: return Py_BuildValue("dd", extrema.f[0], extrema.f[1]); - case IMAGING_TYPE_SPECIAL: + case IMAGING_TYPE_I16: if (self->image->mode == IMAGING_MODE_I_16) { return Py_BuildValue("HH", extrema.s[0], extrema.s[1]); } diff --git a/src/libImaging/Fill.c b/src/libImaging/Fill.c index 25344cf3a7e..38f8ca963a2 100644 --- a/src/libImaging/Fill.c +++ b/src/libImaging/Fill.c @@ -32,7 +32,7 @@ ImagingFill(Imaging im, const void *colour) { int xsize = im->xsize; int ysize = im->ysize; - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { /* use generic API */ ImagingAccess access = ImagingAccessNew(im); if (access) { diff --git a/src/libImaging/Filter.c b/src/libImaging/Filter.c index 76b5cd486f2..77a6345a6ff 100644 --- a/src/libImaging/Filter.c +++ b/src/libImaging/Filter.c @@ -156,7 +156,7 @@ ImagingFilter3x3(Imaging imOut, Imaging im, const float *kernel, float offset) { } } else { int bigendian = 0; - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { if ( im->mode == IMAGING_MODE_I_16B #ifdef WORDS_BIGENDIAN @@ -173,12 +173,12 @@ ImagingFilter3x3(Imaging imOut, Imaging im, const float *kernel, float offset) { UINT8 *restrict out = (UINT8 *)imOut->image[y]; out[0] = in0[0]; - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { out[1] = in0[1]; } for (x = 1; x < xsize - 1; x++) { float ss = offset; - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { ss += kernel_i16(3, in1, x, &kernel[0], bigendian); ss += kernel_i16(3, in0, x, &kernel[3], bigendian); ss += kernel_i16(3, in_1, x, &kernel[6], bigendian); @@ -192,7 +192,7 @@ ImagingFilter3x3(Imaging imOut, Imaging im, const float *kernel, float offset) { out[x] = clip8(ss); } } - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { out[x * 2] = in0[x * 2]; out[x * 2 + 1] = in0[x * 2 + 1]; } else { @@ -316,7 +316,7 @@ ImagingFilter5x5(Imaging imOut, Imaging im, const float *kernel, float offset) { } } else { int bigendian = 0; - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { if ( im->mode == IMAGING_MODE_I_16B #ifdef WORDS_BIGENDIAN @@ -336,13 +336,13 @@ ImagingFilter5x5(Imaging imOut, Imaging im, const float *kernel, float offset) { out[0] = in0[0]; out[1] = in0[1]; - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { out[2] = in0[2]; out[3] = in0[3]; } for (x = 2; x < xsize - 2; x++) { float ss = offset; - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { ss += kernel_i16(5, in2, x, &kernel[0], bigendian); ss += kernel_i16(5, in1, x, &kernel[5], bigendian); ss += kernel_i16(5, in0, x, &kernel[10], bigendian); @@ -360,7 +360,7 @@ ImagingFilter5x5(Imaging imOut, Imaging im, const float *kernel, float offset) { out[x] = clip8(ss); } } - if (im->type == IMAGING_TYPE_SPECIAL) { + if (im->type == IMAGING_TYPE_I16) { out[x * 2 + 0] = in0[x * 2 + 0]; out[x * 2 + 1] = in0[x * 2 + 1]; out[x * 2 + 2] = in0[x * 2 + 2]; @@ -470,8 +470,7 @@ ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32 *kernel, FLOAT32 o Imaging imOut; ImagingSectionCookie cookie; - if (im->type == IMAGING_TYPE_FLOAT32 || - (im->type == IMAGING_TYPE_SPECIAL && im->bands != 1)) { + if (im->type == IMAGING_TYPE_FLOAT32) { return (Imaging)ImagingError_ModeError(); } diff --git a/src/libImaging/Geometry.c b/src/libImaging/Geometry.c index 2186f95f8e5..1bf92e26efa 100644 --- a/src/libImaging/Geometry.c +++ b/src/libImaging/Geometry.c @@ -713,7 +713,7 @@ getfilter(Imaging im, int filterid) { switch (im->type) { case IMAGING_TYPE_UINT8: return nearest_filter8; - case IMAGING_TYPE_SPECIAL: + case IMAGING_TYPE_I16: return nearest_filter16; } } else { @@ -1032,7 +1032,7 @@ ImagingTransformAffine( return (Imaging)ImagingError_ModeError(); } - if (filterid || imIn->type == IMAGING_TYPE_SPECIAL) { + if (filterid || imIn->type == IMAGING_TYPE_I16) { return ImagingGenericTransform( imOut, imIn, x0, y0, x1, y1, affine_transform, a, filterid, fill ); diff --git a/src/libImaging/GetBBox.c b/src/libImaging/GetBBox.c index 7a57f6894a0..45fe717c5c2 100644 --- a/src/libImaging/GetBBox.c +++ b/src/libImaging/GetBBox.c @@ -209,7 +209,7 @@ ImagingGetExtrema(Imaging im, void *extrema) { memcpy(extrema, &fmin, sizeof(fmin)); memcpy(((char *)extrema) + sizeof(fmin), &fmax, sizeof(fmax)); break; - case IMAGING_TYPE_SPECIAL: + case IMAGING_TYPE_I16: if (im->mode == IMAGING_MODE_I_16) { UINT16 v; UINT8 *pixel = *im->image8; diff --git a/src/libImaging/Imaging.h b/src/libImaging/Imaging.h index 472bda5d0fd..dbb585d281d 100644 --- a/src/libImaging/Imaging.h +++ b/src/libImaging/Imaging.h @@ -70,7 +70,7 @@ typedef struct ImagingPaletteInstance *ImagingPalette; #define IMAGING_TYPE_UINT8 0 #define IMAGING_TYPE_INT32 1 #define IMAGING_TYPE_FLOAT32 2 -#define IMAGING_TYPE_SPECIAL 3 /* check mode for details */ +#define IMAGING_TYPE_I16 3 typedef struct { char *ptr; diff --git a/src/libImaging/Point.c b/src/libImaging/Point.c index 8f6d47c770f..dcf88daa586 100644 --- a/src/libImaging/Point.c +++ b/src/libImaging/Point.c @@ -244,7 +244,7 @@ ImagingPointTransform(Imaging imIn, double scale, double offset) { } ImagingSectionLeave(&cookie); break; - case IMAGING_TYPE_SPECIAL: + case IMAGING_TYPE_I16: if (imIn->mode == IMAGING_MODE_I_16) { ImagingSectionEnter(&cookie); for (y = 0; y < imIn->ysize; y++) { diff --git a/src/libImaging/RankFilter.c b/src/libImaging/RankFilter.c index 9b13b103283..fc8ce2db96d 100644 --- a/src/libImaging/RankFilter.c +++ b/src/libImaging/RankFilter.c @@ -64,7 +64,7 @@ MakeRankFunction(UINT8) MakeRankFunction(INT32) MakeRankFunction(FLOAT32) int x, y; int i, margin, size2; - if (!im || im->bands != 1 || im->type == IMAGING_TYPE_SPECIAL) { + if (!im || im->bands != 1 || im->type == IMAGING_TYPE_I16) { return (Imaging)ImagingError_ModeError(); } diff --git a/src/libImaging/Reduce.c b/src/libImaging/Reduce.c index a4e58ced81b..dfdfa448bd4 100644 --- a/src/libImaging/Reduce.c +++ b/src/libImaging/Reduce.c @@ -1452,11 +1452,8 @@ ImagingReduce(Imaging imIn, int xscale, int yscale, int box[4]) { ImagingSectionCookie cookie; Imaging imOut = NULL; - if (imIn->mode == IMAGING_MODE_P || imIn->mode == IMAGING_MODE_1) { - return (Imaging)ImagingError_ModeError(); - } - - if (imIn->type == IMAGING_TYPE_SPECIAL) { + if (imIn->mode == IMAGING_MODE_P || imIn->mode == IMAGING_MODE_1 || + imIn->type == IMAGING_TYPE_I16) { return (Imaging)ImagingError_ModeError(); } diff --git a/src/libImaging/Resample.c b/src/libImaging/Resample.c index c25383a70e4..473a79cfa51 100644 --- a/src/libImaging/Resample.c +++ b/src/libImaging/Resample.c @@ -717,13 +717,9 @@ ImagingResample(Imaging imIn, int xsize, int ysize, int filter, float box[4]) { return (Imaging)ImagingError_ModeError(); } - if (imIn->type == IMAGING_TYPE_SPECIAL) { - if (isModeI16(imIn->mode)) { - ResampleHorizontal = _ImagingResampleHorizontal_16bpc; - ResampleVertical = _ImagingResampleVertical_16bpc; - } else { - return (Imaging)ImagingError_ModeError(); - } + if (imIn->type == IMAGING_TYPE_I16) { + ResampleHorizontal = _ImagingResampleHorizontal_16bpc; + ResampleVertical = _ImagingResampleVertical_16bpc; } else if (imIn->image8) { ResampleHorizontal = _ImagingResampleHorizontal_8bpc; ResampleVertical = _ImagingResampleVertical_8bpc; diff --git a/src/libImaging/Storage.c b/src/libImaging/Storage.c index eae4c988f89..1c3f912f808 100644 --- a/src/libImaging/Storage.c +++ b/src/libImaging/Storage.c @@ -127,7 +127,7 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) { /* 16-bit raw integer images */ im->bands = 1; im->pixelsize = 2; - im->type = IMAGING_TYPE_SPECIAL; + im->type = IMAGING_TYPE_I16; strcpy(im->arrow_band_format, "s"); strcpy(im->band_names[0], "I");