mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merged BGRa test into Tests/test_lib_pack.py
This commit is contained in:
parent
916ea94052
commit
28ede3a327
|
@ -10,11 +10,11 @@ class TestLibPack(PillowTestCase):
|
|||
|
||||
def test_pack(self):
|
||||
|
||||
def pack(mode, rawmode):
|
||||
def pack(mode, rawmode, in_data=(1, 2, 3, 4)):
|
||||
if len(mode) == 1:
|
||||
im = Image.new(mode, (1, 1), 1)
|
||||
im = Image.new(mode, (1, 1), in_data[0])
|
||||
else:
|
||||
im = Image.new(mode, (1, 1), (1, 2, 3, 4)[:len(mode)])
|
||||
im = Image.new(mode, (1, 1), in_data[:len(mode)])
|
||||
|
||||
if py3:
|
||||
return list(im.tobytes("raw", rawmode))
|
||||
|
@ -47,6 +47,8 @@ class TestLibPack(PillowTestCase):
|
|||
self.assertEqual(pack("RGBX", "RGBX"), [1, 2, 3, 4]) # 4->255?
|
||||
|
||||
self.assertEqual(pack("RGBA", "RGBA"), [1, 2, 3, 4])
|
||||
self.assertEqual(pack("RGBA", "BGRa"), [0, 0, 0, 4])
|
||||
self.assertEqual(pack("RGBA", "BGRa", in_data=(20, 30, 40, 50)), [8, 6, 4, 50])
|
||||
|
||||
self.assertEqual(pack("RGBa", "RGBa"), [1, 2, 3, 4])
|
||||
self.assertEqual(pack("RGBa", "BGRa"), [3, 2, 1, 4])
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
from helper import unittest, PillowTestCase
|
||||
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class TestBGRa(PillowTestCase):
|
||||
|
||||
def test_bgra(self):
|
||||
RGBA_RED_50 = b'\xff\x00\x00\x80' # 50% red RGBA
|
||||
BGRa_RED_50 = b'\x00\x00\x80\x80' # 50% red BGRa
|
||||
RGBa_RED_50 = b'\x80\x00\x00\x80' # 50% red RGBa
|
||||
|
||||
im = Image.frombuffer("RGBA", (1, 1), BGRa_RED_50, "raw", "BGRa", 4, 1)
|
||||
self.assertEqual(im.tobytes(), RGBA_RED_50)
|
||||
self.assertEqual(im.tobytes('raw', 'BGRa'), BGRa_RED_50)
|
||||
|
||||
im = Image.frombuffer("RGBa", (1, 1), BGRa_RED_50, "raw", "BGRa", 4, 1)
|
||||
self.assertEqual(im.tobytes(), RGBa_RED_50)
|
||||
self.assertEqual(im.tobytes('raw', 'BGRa'), BGRa_RED_50)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Reference in New Issue
Block a user