Trammell Hudson avatar Trammell Hudson committed a7e0fce

Hacked up version of phooky unpackbits.py

Comments (0)

Files changed (1)

+#!/usr/bin/python
+import sys
+
+skip = int(sys.argv[1])
+count = int(sys.argv[2])
+sys.stdin.read(skip)
+
+offset = skip
+
+# Look for the first end of scan line?
+started = 0
+debug = 0
+
+while True:
+    r = sys.stdin.read(1)
+    offset += 1
+    if not r:
+        break
+    n = ord(r[0])
+    if n < 128:
+	count = n + 1
+	if debug:
+		sys.stderr.write(str(offset) + ": COPY "+str(count)+"\n")
+	for i in range(count):
+		c = sys.stdin.read(1)
+		if debug:
+			sys.stderr.write(str(offset) + ": --- " + hex(ord(c)) + "\n")
+		offset += 1
+		if started:
+			sys.stdout.write(c)
+    elif n == 128:
+	if debug:
+		sys.stderr.write(str(offset) + ": SKIP\n")
+        pass
+    elif n < 256:
+        count = (256-n) + 1
+        r = sys.stdin.read(1)
+	offset += 1
+	if debug:
+		sys.stderr.write(str(offset) + ": RPT "+str(count)+": " + hex(ord(r)) + "\n")
+	if started:
+		for i in range(count):
+			sys.stdout.write(r)
+	if not started and ord(r) == 0x00 and count == 8:
+		started = 1
+		sys.stderr.write(str(offset) + ": First scanline started\n")
+    else:
+        sys.stderr.write("ERROR- VAL OUT OF RANGE\n")
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.