mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Remove redundant bytearray
This commit is contained in:
parent
865b17d5cf
commit
4382413bb4
|
@ -71,9 +71,7 @@ class TestFileGif(PillowTestCase):
|
||||||
def check(colors, size, expected_palette_length):
|
def check(colors, size, expected_palette_length):
|
||||||
# make an image with empty colors in the start of the palette range
|
# make an image with empty colors in the start of the palette range
|
||||||
im = Image.frombytes(
|
im = Image.frombytes(
|
||||||
"P",
|
"P", (colors, colors), bytes(range(256 - colors, 256)) * colors
|
||||||
(colors, colors),
|
|
||||||
bytes(bytearray(range(256 - colors, 256)) * colors),
|
|
||||||
)
|
)
|
||||||
im = im.resize((size, size))
|
im = im.resize((size, size))
|
||||||
outfile = BytesIO()
|
outfile = BytesIO()
|
||||||
|
@ -103,7 +101,7 @@ class TestFileGif(PillowTestCase):
|
||||||
check(256, 511, 256)
|
check(256, 511, 256)
|
||||||
|
|
||||||
def test_optimize_full_l(self):
|
def test_optimize_full_l(self):
|
||||||
im = Image.frombytes("L", (16, 16), bytes(bytearray(range(256))))
|
im = Image.frombytes("L", (16, 16), bytes(range(256)))
|
||||||
test_file = BytesIO()
|
test_file = BytesIO()
|
||||||
im.save(test_file, "GIF", optimize=True)
|
im.save(test_file, "GIF", optimize=True)
|
||||||
self.assertEqual(im.mode, "L")
|
self.assertEqual(im.mode, "L")
|
||||||
|
@ -632,7 +630,7 @@ class TestFileGif(PillowTestCase):
|
||||||
# that's > 128 items where the transparent color is actually
|
# that's > 128 items where the transparent color is actually
|
||||||
# the top palette entry to trigger the bug.
|
# the top palette entry to trigger the bug.
|
||||||
|
|
||||||
data = bytes(bytearray(range(1, 254)))
|
data = bytes(range(1, 254))
|
||||||
palette = ImagePalette.ImagePalette("RGB", list(range(256)) * 3)
|
palette = ImagePalette.ImagePalette("RGB", list(range(256)) * 3)
|
||||||
|
|
||||||
im = Image.new("L", (253, 1))
|
im = Image.new("L", (253, 1))
|
||||||
|
@ -680,7 +678,7 @@ class TestFileGif(PillowTestCase):
|
||||||
|
|
||||||
im = hopper("P")
|
im = hopper("P")
|
||||||
im_l = Image.frombytes("L", im.size, im.tobytes())
|
im_l = Image.frombytes("L", im.size, im.tobytes())
|
||||||
palette = bytes(bytearray(im.getpalette()))
|
palette = bytes(im.getpalette())
|
||||||
|
|
||||||
out = self.tempfile("temp.gif")
|
out = self.tempfile("temp.gif")
|
||||||
im_l.save(out, palette=palette)
|
im_l.save(out, palette=palette)
|
||||||
|
@ -695,7 +693,7 @@ class TestFileGif(PillowTestCase):
|
||||||
# Forcing a non-straight grayscale palette.
|
# Forcing a non-straight grayscale palette.
|
||||||
|
|
||||||
im = hopper("P")
|
im = hopper("P")
|
||||||
palette = bytes(bytearray([255 - i // 3 for i in range(768)]))
|
palette = bytes([255 - i // 3 for i in range(768)])
|
||||||
|
|
||||||
out = self.tempfile("temp.gif")
|
out = self.tempfile("temp.gif")
|
||||||
im.save(out, palette=palette)
|
im.save(out, palette=palette)
|
||||||
|
@ -736,7 +734,7 @@ class TestFileGif(PillowTestCase):
|
||||||
im.putpalette(ImagePalette.ImagePalette("RGB"))
|
im.putpalette(ImagePalette.ImagePalette("RGB"))
|
||||||
im.info = {"background": 0}
|
im.info = {"background": 0}
|
||||||
|
|
||||||
passed_palette = bytes(bytearray([255 - i // 3 for i in range(768)]))
|
passed_palette = bytes([255 - i // 3 for i in range(768)])
|
||||||
|
|
||||||
GifImagePlugin._FORCE_OPTIMIZE = True
|
GifImagePlugin._FORCE_OPTIMIZE = True
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TestLibPack(PillowTestCase):
|
||||||
|
|
||||||
if isinstance(data, int):
|
if isinstance(data, int):
|
||||||
data_len = data * len(pixels)
|
data_len = data * len(pixels)
|
||||||
data = bytes(bytearray(range(1, data_len + 1)))
|
data = bytes(range(1, data_len + 1))
|
||||||
|
|
||||||
self.assertEqual(data, im.tobytes("raw", rawmode))
|
self.assertEqual(data, im.tobytes("raw", rawmode))
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ class TestLibUnpack(PillowTestCase):
|
||||||
"""
|
"""
|
||||||
if isinstance(data, int):
|
if isinstance(data, int):
|
||||||
data_len = data * len(pixels)
|
data_len = data * len(pixels)
|
||||||
data = bytes(bytearray(range(1, data_len + 1)))
|
data = bytes(range(1, data_len + 1))
|
||||||
|
|
||||||
im = Image.frombytes(mode, (len(pixels), 1), data, "raw", rawmode, 0, 1)
|
im = Image.frombytes(mode, (len(pixels), 1), data, "raw", rawmode, 0, 1)
|
||||||
|
|
||||||
|
|
|
@ -1742,7 +1742,7 @@ class AppendingTiffWriter:
|
||||||
# pad to 16 byte boundary
|
# pad to 16 byte boundary
|
||||||
padBytes = 16 - pos % 16
|
padBytes = 16 - pos % 16
|
||||||
if 0 < padBytes < 16:
|
if 0 < padBytes < 16:
|
||||||
self.f.write(bytes(bytearray(padBytes)))
|
self.f.write(bytes(padBytes))
|
||||||
self.offsetOfNewPage = self.f.tell()
|
self.offsetOfNewPage = self.f.tell()
|
||||||
|
|
||||||
def setEndian(self, endian):
|
def setEndian(self, endian):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user