Take a block of (2, 4, or 8) values, and pack them into a single byte.
(block)
| 972 | spb = int(8 / bitdepth) |
| 973 | |
| 974 | def make_byte(block): |
| 975 | """Take a block of (2, 4, or 8) values, |
| 976 | and pack them into a single byte. |
| 977 | """ |
| 978 | |
| 979 | res = 0 |
| 980 | for v in block: |
| 981 | res = (res << bitdepth) + v |
| 982 | return res |
| 983 | |
| 984 | for row in rows: |
| 985 | a = bytearray(row) |