Skip to content

Commit

Permalink
refactoring and scratch image. fix break typo, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspesla committed Dec 18, 2015
1 parent 8220c9a commit 69fc4f3
Show file tree
Hide file tree
Showing 4 changed files with 2,341 additions and 904 deletions.
Binary file added cat.rgf
Binary file not shown.
29 changes: 29 additions & 0 deletions create_rgf_from_png.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from PIL import Image
from bitstring import BitArray
import sys
im = Image.open(sys.argv[1])
pix = im.load()
w=im.size[0]
h=im.size[1]

s = BitArray(bytearray([w,h]));

bits = [ ]
for j in range(h):
for i in range(w):
if len(bits) == 8:
s += bits
bits = [ ]
if pix[i,j] == 1:
bits.insert(0,0)
else:
bits.insert(0,1)
# pad row to 8 bits
dif = 8 - len(bits)
for x in range(0, dif-1):
bits.insert(0,0)

f = open('output.rgf', 'wb')
s.tofile(f)

print s.hex
Loading

0 comments on commit 69fc4f3

Please sign in to comment.