Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

read the stitches bitches

  • Loading branch information...
commit cd2f0d4080decf79114da6f214c5df668829f166 1 parent 0308e8f
@ludflu authored
Showing with 18 additions and 15 deletions.
  1. +12 −11 Embroidery.py
  2. +2 −2 penguin.json
  3. +4 −2 test.py
View
23 Embroidery.py
@@ -9,7 +9,7 @@ def __init__(self):
return None
def readI(self,indx):
- bla = struct.unpack( "!B", self.bs[indx] )
+ bla = struct.unpack( "B", self.bs[indx] )
return int ( bla[0] )
def readStchs(self,indx):
@@ -17,37 +17,38 @@ def readStchs(self,indx):
oldx = 0
oldy = 0
while (True):
+ indx += 1
v1 = self.readI(indx)
indx += 1
v2 = self.readI(indx)
- if (v1 == 255 and v2==0):
+ if (v1 == 255) and (v2==0):
self.blocks.append(sts);
- print "end of image"
+ #print "end of image"
return self.blocks
- elif (v1 == 254 and v2 == 176):
+ elif (v1 == 254) and (v2 == 176):
indx += 1
self.blocks.append(sts);
sts = []
- print "color change"
+ #print "color change"
continue
if (v1 & 0x80):
- v1 = ((v1 & 15) << 8) + v2
- if (v1 & 2048):
+ v1 = ((v1 & 15) << 8 ) + v2
+ if (v1 & 2048 == 0x800):
v1 -= 4096
indx += 1
v2 = self.readI(indx)
- elif (v1 & 64):
+ elif (v1 & 64 > 0):
v1 -= 128
if (v2 & 0x80):
indx += 1
v2 = ((v2 & 15) << 8) + self.readI(indx)
- if (v2 & 2048):
+ if (v2 & 2048 == 0x800):
v2 -= 4096
else:
- if (v2 & 64):
+ if (v2 & 64 > 0 ):
v2 -= 128
v1 = v1 + oldx
@@ -72,7 +73,7 @@ def load(self,fname):
pec = struct.unpack('<I', pecb + '\0' )
self.pec = pec[0]
self.bs = bs
- self.readStchs(self.pec + 533)
+ self.readStchs(self.pec + 533 )
self.bs= ""
#print self.blocks
return None
View
4 penguin.json
2 additions, 2 deletions not shown
View
6 test.py
@@ -4,7 +4,7 @@
import json
def convert_to_builtin_type(obj):
- print 'default(', repr(obj), ')'
+ #print 'default(', repr(obj), ')'
# Convert objects to a dictionary of their representation
d = { '__class__':obj.__class__.__name__,
'__module__':obj.__module__,
@@ -15,4 +15,6 @@ def convert_to_builtin_type(obj):
x = Embroidery.Embroidery()
x.load("Pinguin23.pes")
-#print json.dumps(x, default=convert_to_builtin_type)
+#x.load("UT1997.PES")
+print "var bird = "
+print json.dumps(x, default=convert_to_builtin_type)
Please sign in to comment.
Something went wrong with that request. Please try again.