License | MIT |
---|---|
Maintainer | Alexander Isenko <alex.isenko@googlemail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Format.Converter
exports the functions that create the .c
or .raw
files when the FilePath
is given
Both pictureToRaw
and pictureToC
accept these picture formats
.gif
.png
.jpg / .jpe / .jpeg
.bmp
.tga
If it's not any of those formats, an error gets thrown If there is an error while decoding the pictures it gets printed out
- pictureToRaw :: FilePath -> FilePath -> IO ()
- pictureToC :: Platform -> FilePath -> FilePath -> IO ()
Documentation
pictureToRaw :: FilePath -> FilePath -> IO () Source
pictureToRaw takes a picture, decodes it, parses every pixel to a 4 digit RGB565 hex and saves it to
a file with the same name and a .raw
extention in the specified directory
This function takes two arguments
- first
FilePath
is the directory to save the file to - second
FilePath
is the filepath to the picture
Possible errors:
- Can throw an error if the picture format is not supported
- If there is an error while decoding the pictures the file gets skipped and an error message is printed out
Results:
If the conversion was successful, a message gets printed
cat_01_bmp_120x120.bmp --> cat_01_bmp_120x120.raw
Example usage: (assumed that the picture is in the directory where ghci was started)
λ> dir <- getCurrentDirectory λ> pictureToRaw dir "cat_01_bmp_120x120.bmp" cat_01_bmp_120x120.bmp --> cat_01_bmp_120x120.raw
pictureToC :: Platform -> FilePath -> FilePath -> IO () Source
pictureToC takes a picture, decodes it, parses every pixel to a 4 digit RGB565 hex, adds the header
based on the desired platform and saves it to a file with the same name and a .c
extention in the specified
directory
This function takes three arguments
Platform
is the desired platform to convert to- first
FilePath
is the directory to save the file to - second
FilePath
is the filepath to the picture
Possible errors:
- Can throw an error if the picture format is not supported
- If there is an error while decoding the pictures the file gets skipped and an error message is printed out
Results:
If the conversion was successful, a message gets printed
cat_01_bmp_120x120.bmp --> cat_01_bmp_120x120.c
Example usage: (assumed that the picture is in the directory where ghci was started)
λ> dir <- getCurrentDirectory λ> pictureToC AVR dir "cat_01_bmp_120x120.bmp" cat_01_bmp_120x120.bmp --> cat_01_bmp_120x120.c