やりたいこと
昨日まででヘッダーは読み込めるようになったため、今度はピクセルの情報を読みだす。
プログラム
プログラムは以下の感じ。import System.IO import System.Environment (getArgs) main = do args <- getArgs if length args <= 1 then do print "usage : ./pgm-input input.pgm output.pgm" else do infile <- openFile (head args) ReadMode -- Read PGM Header pgm_type <- hGetLine infile pgm_comment <- hGetLine infile pgm_max_brightness <- hGetLine infile pgm_size <- hGetLine infile -- Read PGM Pixels- src_pixels <- hGetContents infile -- Output PGM File fh <- openFile (args !! 1) WriteMode hPutStrLn fh pgm_type hPutStrLn fh pgm_comment hPutStrLn fh pgm_max_brightness hPutStrLn fh contents hPutStrLn fh pgm_size hPutStrLn fh src_pixels hClose infile hClose fh