Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 2nd, 2013  |  syntax: None  |  size: 1.53 KB  |  views: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff --git a/process_dvi.py b/process_dvi.py
  2. index 0c649dd..2c23384 100644
  3. --- a/process_dvi.py
  4. +++ b/process_dvi.py
  5. @@ -8,6 +8,7 @@ def find_control_position(raw_words):
  6.         control_counter = 0
  7.         for w1, w2 in zip(raw_words, raw_words[1:]):
  8.                 lw = w2 | (w1 << 10)
  9. +               lw = w1 | (w2 << 10)
  10.                 found_control = False
  11.                 for i in range(10):
  12.                         e = (lw >> i) & (2**10 - 1)
  13. @@ -29,7 +30,7 @@ def find_control_position(raw_words):
  14.  def char_align(raw_words, control_position):
  15.         r = []
  16.         for w1, w2 in zip(raw_words, raw_words[1:]):
  17. -               lw = w2 | (w1 << 10)
  18. +               lw = w1 | (w2 << 10)
  19.                 e = (lw >> control_position) & (2**10 - 1)
  20.                 r.append(e)
  21.         return r
  22. @@ -69,6 +70,22 @@ def main():
  23.                 while word:
  24.                         raw_words.append(struct.unpack(">H", word)[0])
  25.                         word = f.read(2)
  26. +
  27. +       raw_words = raw_words[4:-4];
  28. +
  29. +       r = []
  30. +       for i in range(0, len(raw_words) - 7, 8):
  31. +               r.append(raw_words[i + 7])
  32. +               r.append(raw_words[i + 6])
  33. +               r.append(raw_words[i + 5])
  34. +               r.append(raw_words[i + 4])
  35. +               r.append(raw_words[i + 3])
  36. +               r.append(raw_words[i + 2])
  37. +               r.append(raw_words[i + 1])
  38. +               r.append(raw_words[i + 0])
  39. +
  40. +       raw_words = r
  41. +
  42.         control_position = find_control_position(raw_words)
  43.         print("Syncing characters at {0}".format(control_position))
  44.         chars = char_align(raw_words, control_position)
  45. @@ -89,7 +106,7 @@ def main():
  46.                 prev_de = de
  47.         #for row in img:
  48.         #       print(len(row))
  49. -       img = [row for row in img if len(row) == 633] # FIXME
  50. +       img = [row for row in img if len(row) == 640] # FIXME
  51.         write_image("tst.ppm", img)
  52.  
  53.  main()
clone this paste RAW Paste Data