I have a very little experience in Haskell and I want to write a simple ray tracer for practice. Because I didn't want to use GUI tools like wxHaskell (I think it'll take a lot of time to learn how to use them), I decided to simply save the output image to BMP file. But I have a problem here:
module Main where
import Codec.BMP
import qualified Data.ByteString as BS
main = do
Right bmp <- readBMP "grass.bmp"
BS.putStrLn $ BS.take 4 $ unpackBMPToRGBA32 bmp
Here I just want to take first pixel of the image and print its RGBA values. But I get an error saying
Couldn't match expected type `BS.ByteString'
with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString'
In the return type of a call of `unpackBMPToRGBA32'
In the second argument of `($)', namely `unpackBMPToRGBA32 bmp'
In the second argument of `($)', namely
`BS.take 4 $ unpackBMPToRGBA32 bmp'
What am I doing wrong? How can I take the pixels of the image and print their values?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…