Permalink
Browse files

not working right

  • Loading branch information...
1 parent cf8c32d commit 83d5652b2eda782a61b9439fec9584de2928aa8b @ludflu committed Aug 5, 2011
Showing with 7 additions and 7 deletions.
  1. +7 −7 Codec/Binary/Embroidery/PCS.hs
@@ -36,7 +36,6 @@ mkPt (Stitch x y) = (fromIntegral x , fromIntegral (-y ))
buildStitch x y =
Stitch (fromIntegral x) (fromIntegral y)
-
readColors :: DL.DList StitchColor -> Int -> Parser [StitchColor]
readColors colors 0 = return (DL.toList colors)
readColors colors count = do
@@ -47,16 +46,16 @@ readColors colors count = do
let c = StitchColor (fromIntegral r) (fromIntegral g) (fromIntegral b )
readColors (DL.snoc colors c) (count-1)
-serialiseCoord :: Word8 -> [Word8]
+serialiseCoord :: Int -> [Word8]
serialiseCoord n =
- let three = n `div` 65536
- two = (n - (three * 65536)) `div` 256
- one = n - (three * 65536) - (two * 256) in
- [one,two,three, 0]
+ let three = n `div` 65536
+ two = (n - (three * 65536)) `div` 256
+ one = n - (three * 65536) - (two * 256) in
+ map fromIntegral [one,two,three, 0]
serialiseStitch :: Stitch -> Put
serialiseStitch (Stitch x y) = do
- let bytes = (serialiseCoord (fromIntegral x)) ++ (serialiseCoord (fromIntegral y)) in
+ let bytes = (serialiseCoord x) ++ (serialiseCoord y) in
mapM_ putWord8 bytes
readStitchBytes :: Parser Int
@@ -86,6 +85,7 @@ parsePCS = do
numcolors <- getWord16be
colors <- readColors DL.empty 16
numStitches <- getWord16le
+ let !bla = if (numStitches ==0 || trace (show numStitches) False ) then 1 else 0
stitches <- parseStitches DL.empty DL.empty (fromIntegral numStitches )
return (EmbFile (fromIntegral size) 16 stitches colors)

0 comments on commit 83d5652

Please sign in to comment.