Created
April 3, 2012 17:48
-
-
Save h-hirai/2294086 to your computer and use it in GitHub Desktop.
tried to use Codec.BMP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Codec.BMP | |
import Data.Word (Word8) | |
import Data.ByteString (pack) | |
pixcelToFlatByteString height width px = pack $ rep height $ rep width px | |
where rep n = concat . replicate n | |
pixcelToPackedRGBA height width px = | |
packRGBA32ToBMP width height $ pixcelToFlatByteString height width px | |
main = do | |
let | |
width = 128 | |
height = 32 | |
red = pixcelToPackedRGBA height width [255,0,0,0] | |
green = pixcelToPackedRGBA height width [0,255,0,0] | |
blue = pixcelToPackedRGBA height width [0,0,255,0] | |
black = pixcelToPackedRGBA height width [0,0,0,255] | |
writeBMP "trial.red.bmp" red | |
writeBMP "trial.green.bmp" green | |
writeBMP "trial.blue.bmp" blue | |
writeBMP "trial.black.bmp" black |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment