MCPcopy Index your code
hub / github.com/python-pillow/Pillow / test_mesh

Method test_mesh

Tests/test_image_transform.py:112–149  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

110 assert transformed.getpixel((w - 1, h - 1)) == expected_pixel
111
112 def test_mesh(self) -> None:
113 # this should be a checkerboard of halfsized hoppers in ul, lr
114 im = hopper("RGBA")
115 w, h = im.size
116 transformed = im.transform(
117 im.size,
118 Image.Transform.MESH,
119 (
120 (
121 (0, 0, w // 2, h // 2), # box
122 (0, 0, 0, h, w, h, w, 0), # ul -> ccw around quad
123 ),
124 (
125 (w // 2, h // 2, w, h), # box
126 (0, 0, 0, h, w, h, w, 0), # ul -> ccw around quad
127 ),
128 ),
129 Image.Resampling.BILINEAR,
130 )
131
132 scaled = im.transform(
133 (w // 2, h // 2),
134 Image.Transform.AFFINE,
135 (2, 0, 0, 0, 2, 0),
136 Image.Resampling.BILINEAR,
137 )
138
139 checker = Image.new("RGBA", im.size)
140 checker.paste(scaled, (0, 0))
141 checker.paste(scaled, (w // 2, h // 2))
142
143 assert_image_equal(transformed, checker)
144
145 # now, check to see that the extra area is (0, 0, 0, 0)
146 blank = Image.new("RGBA", (w // 2, h // 2), (0, 0, 0, 0))
147
148 assert_image_equal(blank, transformed.crop((w // 2, 0, w, h // 2)))
149 assert_image_equal(blank, transformed.crop((0, h // 2, w // 2, h)))
150
151 def _test_alpha_premult(
152 self, op: Callable[[Image.Image, tuple[int, int]], Image.Image]

Callers 1

test_blank_fillMethod · 0.95

Calls 6

hopperFunction · 0.85
assert_image_equalFunction · 0.85
newMethod · 0.80
cropMethod · 0.80
transformMethod · 0.45
pasteMethod · 0.45

Tested by

no test coverage detected