summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2016-06-07 11:48:40 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2016-06-07 17:02:08 +0300
commit96b69bd1a45707f9b675f828164709bca9ced3bd (patch)
treed41de2f689ce48fdcf7e8bb30467d77a399e5dbf /py
parent6ec82c4a50a82964c9be2bd40dc7097e8dcc8441 (diff)
py/gamma.py: Make gamma table calculations more generic
Diffstat (limited to 'py')
-rw-r--r--py/gamma.py13
1 files 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);