mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +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
|
||||
pixel values for multiband images.
|
||||
"""
|
||||
|
||||
(x, y) = self.check_xy(xy)
|
||||
(x, y) = 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)
|
||||
|
||||
putpixel = __setitem__
|
||||
|
|
|
@ -471,7 +471,12 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
|
|||
INT32 i;
|
||||
FLOAT32 f;
|
||||
} 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) {
|
||||
PyErr_SetString(PyExc_IndexError, outside_image);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue
Block a user