Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/process_dvi.py b/process_dvi.py
- index 0c649dd..2c23384 100644
- --- a/process_dvi.py
- +++ b/process_dvi.py
- @@ -8,6 +8,7 @@ def find_control_position(raw_words):
- control_counter = 0
- for w1, w2 in zip(raw_words, raw_words[1:]):
- lw = w2 | (w1 << 10)
- + lw = w1 | (w2 << 10)
- found_control = False
- for i in range(10):
- e = (lw >> i) & (2**10 - 1)
- @@ -29,7 +30,7 @@ def find_control_position(raw_words):
- def char_align(raw_words, control_position):
- r = []
- for w1, w2 in zip(raw_words, raw_words[1:]):
- - lw = w2 | (w1 << 10)
- + lw = w1 | (w2 << 10)
- e = (lw >> control_position) & (2**10 - 1)
- r.append(e)
- return r
- @@ -69,6 +70,22 @@ def main():
- while word:
- raw_words.append(struct.unpack(">H", word)[0])
- word = f.read(2)
- +
- + raw_words = raw_words[4:-4];
- +
- + r = []
- + for i in range(0, len(raw_words) - 7, 8):
- + r.append(raw_words[i + 7])
- + r.append(raw_words[i + 6])
- + r.append(raw_words[i + 5])
- + r.append(raw_words[i + 4])
- + r.append(raw_words[i + 3])
- + r.append(raw_words[i + 2])
- + r.append(raw_words[i + 1])
- + r.append(raw_words[i + 0])
- +
- + raw_words = r
- +
- control_position = find_control_position(raw_words)
- print("Syncing characters at {0}".format(control_position))
- chars = char_align(raw_words, control_position)
- @@ -89,7 +106,7 @@ def main():
- prev_de = de
- #for row in img:
- # print(len(row))
- - img = [row for row in img if len(row) == 633] # FIXME
- + img = [row for row in img if len(row) == 640] # FIXME
- write_image("tst.ppm", img)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement