From 96b69bd1a45707f9b675f828164709bca9ced3bd Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 7 Jun 2016 11:48:40 +0300 Subject: py/gamma.py: Make gamma table calculations more generic --- py/gamma.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/py/gamma.py b/py/gamma.py index 7ecd19d..6dfd935 100644 --- a/py/gamma.py +++ b/py/gamma.py @@ -19,15 +19,16 @@ pykms.draw_test_pattern(fb); crtc.set_mode(conn, fb, mode) -arr = bytearray(256*2*4) +len=256 +arr = bytearray(len*2*4) view = memoryview(arr).cast("H") -for i in range(256): - g = round(255 * pow(i / 255.0, 1 / 2.2)) +for i in range(len): + g = round(65535 * pow(i / float(len), 1 / 2.2)) - view[i * 4 + 0] = g << 8 - view[i * 4 + 1] = g << 8 - view[i * 4 + 2] = g << 8 + view[i * 4 + 0] = g + view[i * 4 + 1] = g + view[i * 4 + 2] = g view[i * 4 + 3] = 0 gamma = pykms.Blob(card, arr); -- cgit v1.2.3