mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Make _make_gamma_lut() public
This commit is contained in:
parent
17223001df
commit
3c39a44f6e
|
@ -134,7 +134,7 @@ def _make_linear_lut(black, white):
|
|||
return lut
|
||||
|
||||
|
||||
def _make_gamma_lut(exp, mode="RGB"):
|
||||
def make_gamma_lut(exp):
|
||||
lut = []
|
||||
for i in range(256):
|
||||
lut.append(int(((i / 255.0) ** exp) * 255.0 + 0.5))
|
||||
|
|
|
@ -44,6 +44,25 @@ class TestImagePalette(PillowTestCase):
|
|||
self.assertIsInstance(p, ImagePalette)
|
||||
self.assertEqual(p.palette, palette.tobytes())
|
||||
|
||||
def test_make_gamma_lut(self):
|
||||
# Arrange
|
||||
from PIL.ImagePalette import make_gamma_lut
|
||||
exp = 5
|
||||
|
||||
# Act
|
||||
lut = make_gamma_lut(exp)
|
||||
|
||||
# Assert
|
||||
self.assertIsInstance(lut, list)
|
||||
self.assertEqual(len(lut), 256)
|
||||
# Check a few values
|
||||
self.assertEqual(lut[0], 0)
|
||||
self.assertEqual(lut[63], 0)
|
||||
self.assertEqual(lut[127], 8)
|
||||
self.assertEqual(lut[191], 60)
|
||||
self.assertEqual(lut[255], 255)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user