Skip to content

Commit

Permalink
special-case BGR;15 and BGR;16 color values
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Mar 30, 2024
1 parent 980ef07 commit 355d9d9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,15 @@ def _make_new(

@pytest.mark.parametrize("mode", image_modes)
def test_pixels_from_new_image_by_color(self, mode: ImageModeInfo) -> None:
color = 123 if mode.num_bands == 1 else tuple(range(mode.num_bands))
if mode.name in ("BGR;15", "BGR;16"):
# These modes have fewer than 8 bits per band,
# so not all values can be round-tripped.
color = (16, 32, 49)
elif mode.num_bands == 1:
color = 123
else:
color = tuple(range(mode.num_bands))

im = Image.new(mode.name, (2, 2), color=color)

assert im.getpixel((0, 0)) == color
Expand Down

0 comments on commit 355d9d9

Please sign in to comment.