qr-imager-0.1.2.0: src/Data/QRCodes/Image.hs
module Data.QRCodes.Image where
import Data.Word (Word8)
import Codec.Picture.Types as T
import Prelude as P
import qualified Data.Vector.Storable as V
encodePng :: [[Word8]] -> T.Image Word8
encodePng matrix = Image dim dim vector
where dim = P.length matrix
vector = V.map ((*255) . swapWord) $ V.fromList $ P.concat matrix
fattenList :: Int -> [a] -> [a]
fattenList i l = P.concat $ P.foldr ((:) . (P.replicate i)) [] l
swapWord :: Word8 -> Word8
swapWord 1 = 0
swapWord 0 = 1