mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
replace resize implementation
This commit is contained in:
parent
d781d56aa5
commit
aba798af25
13
PIL/Image.py
13
PIL/Image.py
|
@ -876,7 +876,7 @@ class Image:
|
|||
elif self.mode == 'P' and mode == 'RGBA':
|
||||
t = self.info['transparency']
|
||||
delete_trns = True
|
||||
|
||||
|
||||
if isinstance(t, bytes):
|
||||
self.im.putpalettealphas(t)
|
||||
elif isinstance(t, int):
|
||||
|
@ -1539,16 +1539,7 @@ class Image:
|
|||
if self.mode == 'RGBA':
|
||||
return self.convert('RGBa').resize(size, resample).convert('RGBA')
|
||||
|
||||
if resample == ANTIALIAS:
|
||||
# requires stretch support (imToolkit & PIL 1.1.3)
|
||||
try:
|
||||
im = self.im.stretch(size, resample)
|
||||
except AttributeError:
|
||||
raise ValueError("unsupported resampling filter")
|
||||
else:
|
||||
im = self.im.resize(size, resample)
|
||||
|
||||
return self._new(im)
|
||||
return self._new(self.im.resize(size, resample))
|
||||
|
||||
def rotate(self, angle, resample=NEAREST, expand=0):
|
||||
"""
|
||||
|
|
23
_imaging.c
23
_imaging.c
|
@ -1513,9 +1513,26 @@ _resize(ImagingObject* self, PyObject* args)
|
|||
|
||||
imIn = self->image;
|
||||
|
||||
imOut = ImagingNew(imIn->mode, xsize, ysize);
|
||||
if (imOut)
|
||||
(void) ImagingResize(imOut, imIn, filter);
|
||||
if (imIn->xsize == xsize && imIn->ysize == ysize) {
|
||||
imOut = ImagingCopy(imIn);
|
||||
}
|
||||
else if ( ! filter) {
|
||||
double a[6];
|
||||
|
||||
memset(a, 0, sizeof a);
|
||||
a[1] = (double) imIn->xsize / xsize;
|
||||
a[5] = (double) imIn->ysize / ysize;
|
||||
|
||||
imOut = ImagingNew(imIn->mode, xsize, ysize);
|
||||
|
||||
imOut = ImagingTransformAffine(
|
||||
imOut, imIn,
|
||||
0, 0, xsize, ysize,
|
||||
a, filter, 1);
|
||||
}
|
||||
else {
|
||||
imOut = ImagingStretch(imIn, xsize, ysize, filter);
|
||||
}
|
||||
|
||||
return PyImagingNew(imOut);
|
||||
}
|
||||
|
|
|
@ -979,30 +979,6 @@ ImagingTransformQuad(Imaging imOut, Imaging imIn,
|
|||
/* -------------------------------------------------------------------- */
|
||||
/* Convenience functions */
|
||||
|
||||
Imaging
|
||||
ImagingResize(Imaging imOut, Imaging imIn, int filterid)
|
||||
{
|
||||
double a[6];
|
||||
|
||||
if (imOut->xsize == imIn->xsize && imOut->ysize == imIn->ysize)
|
||||
return ImagingCopy2(imOut, imIn);
|
||||
|
||||
memset(a, 0, sizeof a);
|
||||
a[1] = (double) imIn->xsize / imOut->xsize;
|
||||
a[5] = (double) imIn->ysize / imOut->ysize;
|
||||
|
||||
if (!filterid && imIn->type != IMAGING_TYPE_SPECIAL)
|
||||
return ImagingScaleAffine(
|
||||
imOut, imIn,
|
||||
0, 0, imOut->xsize, imOut->ysize,
|
||||
a, 1);
|
||||
|
||||
return ImagingTransformAffine(
|
||||
imOut, imIn,
|
||||
0, 0, imOut->xsize, imOut->ysize,
|
||||
a, filterid, 1);
|
||||
}
|
||||
|
||||
Imaging
|
||||
ImagingRotate(Imaging imOut, Imaging imIn, double theta, int filterid)
|
||||
{
|
||||
|
|
|
@ -285,7 +285,6 @@ extern Imaging ImagingPointTransform(
|
|||
Imaging imIn, double scale, double offset);
|
||||
extern Imaging ImagingPutBand(Imaging im, Imaging imIn, int band);
|
||||
extern Imaging ImagingRankFilter(Imaging im, int size, int rank);
|
||||
extern Imaging ImagingResize(Imaging imOut, Imaging imIn, int filter);
|
||||
extern Imaging ImagingRotate(
|
||||
Imaging imOut, Imaging imIn, double theta, int filter);
|
||||
extern Imaging ImagingRotate90(Imaging imOut, Imaging imIn);
|
||||
|
|
Loading…
Reference in New Issue
Block a user