Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Tests/test_image_transpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

class TestImageTranspose(PillowTestCase):

hopper = {
'L': helper.hopper('L').crop((0, 0, 121, 127)).copy(),
'RGB': helper.hopper('RGB').crop((0, 0, 121, 127)).copy(),
}
hopper = {mode: helper.hopper(mode).crop((0, 0, 121, 127)).copy() for mode in [
'L', 'RGB', 'I;16', 'I;16L', 'I;16B'
]}

def test_flip_left_right(self):
def transpose(mode):
Expand All @@ -25,7 +24,7 @@ def transpose(mode):
self.assertEqual(im.getpixel((1, y-2)), out.getpixel((x-2, y-2)))
self.assertEqual(im.getpixel((x-2, y-2)), out.getpixel((1, y-2)))

for mode in ("L", "RGB"):
for mode in ("L", "RGB", "I;16", "I;16L", "I;16B"):
transpose(mode)

def test_flip_top_bottom(self):
Expand All @@ -41,7 +40,7 @@ def transpose(mode):
self.assertEqual(im.getpixel((1, y-2)), out.getpixel((1, 1)))
self.assertEqual(im.getpixel((x-2, y-2)), out.getpixel((x-2, 1)))

for mode in ("L", "RGB"):
for mode in ("L", "RGB", "I;16", "I;16L", "I;16B"):
transpose(mode)

def test_rotate_90(self):
Expand Down Expand Up @@ -73,7 +72,7 @@ def transpose(mode):
self.assertEqual(im.getpixel((1, y-2)), out.getpixel((x-2, 1)))
self.assertEqual(im.getpixel((x-2, y-2)), out.getpixel((1, 1)))

for mode in ("L", "RGB"):
for mode in ("L", "RGB", "I;16", "I;16L", "I;16B"):
transpose(mode)

def test_rotate_270(self):
Expand Down
12 changes: 10 additions & 2 deletions src/libImaging/Geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ ImagingFlipLeftRight(Imaging imOut, Imaging imIn)
ImagingSectionEnter(&cookie);

if (imIn->image8) {
FLIP_LEFT_RIGHT(UINT8, image8)
if (strncmp(imIn->mode, "I;16", 4) == 0) {
FLIP_LEFT_RIGHT(UINT16, image8)
} else {
FLIP_LEFT_RIGHT(UINT8, image8)
}
} else {
FLIP_LEFT_RIGHT(INT32, image32)
}
Expand Down Expand Up @@ -253,7 +257,11 @@ ImagingRotate180(Imaging imOut, Imaging imIn)

yr = imIn->ysize-1;
if (imIn->image8) {
ROTATE_180(UINT8, image8)
if (strncmp(imIn->mode, "I;16", 4) == 0) {
ROTATE_180(UINT16, image8)
} else {
ROTATE_180(UINT8, image8)
}
} else {
ROTATE_180(INT32, image32)
}
Expand Down