mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-14 03:21:44 +03:00
Image pixels negative index
This commit is contained in:
parent
6a83a440d5
commit
468c405a47
|
@ -88,8 +88,12 @@ class PyAccess(object):
|
||||||
:returns: a pixel value for single band images, a tuple of
|
:returns: a pixel value for single band images, a tuple of
|
||||||
pixel values for multiband images.
|
pixel values for multiband images.
|
||||||
"""
|
"""
|
||||||
|
(x, y) = xy
|
||||||
(x, y) = self.check_xy(xy)
|
if (x < 0):
|
||||||
|
x = self.xsize + x
|
||||||
|
if (y < 0):
|
||||||
|
y = self.ysize + y
|
||||||
|
(x, y) = self.check_xy((x, y))
|
||||||
return self.get_pixel(x, y)
|
return self.get_pixel(x, y)
|
||||||
|
|
||||||
putpixel = __setitem__
|
putpixel = __setitem__
|
||||||
|
|
|
@ -471,7 +471,12 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
|
||||||
INT32 i;
|
INT32 i;
|
||||||
FLOAT32 f;
|
FLOAT32 f;
|
||||||
} pixel;
|
} pixel;
|
||||||
|
if (x < 0){
|
||||||
|
x = im->xsize + x;
|
||||||
|
}
|
||||||
|
if (y < 0){
|
||||||
|
y = im->ysize + y;
|
||||||
|
}
|
||||||
if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) {
|
if (x < 0 || x >= im->xsize || y < 0 || y >= im->ysize) {
|
||||||
PyErr_SetString(PyExc_IndexError, outside_image);
|
PyErr_SetString(PyExc_IndexError, outside_image);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user