AC-PPM-1.1.1: Trivial package for writing PPM images.

Codec.PPM.Text

Description

Generate textual PPM files ("P3"). These are much larger than binary files and slower to generate, but have the advantage of being vaguely human-readable. (Apart from the file header, each line is three decimal numbers representing the RGB values of a single pixel.) Such files will also survive transfer in "text mode" without being mutilated, unlike binary image files.

Synopsis

Documentation

stringPPM :: (Integer, Integer) -> [(Word8, Word8, Word8)] -> ByteStringSource

Given the image size (X pixels, Y pixels) and a list of pixel values (red, green, blue), produce a lazy ByteString containing the PPM data.

putPPM :: Handle -> (Integer, Integer) -> [(Word8, Word8, Word8)] -> IO ()Source

Convenience function: Generate PPM data and write it to the specified Handle. The handle is not closed or flushed afterwards. This allows writing PPM data to network streams, etc. This function does not return until all the data has been completely written. (It may of course throw some kind of I/O exception instead.)

writePPM :: FilePath -> (Integer, Integer) -> [(Word8, Word8, Word8)] -> IO ()Source

Convenience function: Write PPM data directly to a file. If the file does not exist, it is created. If it exists, it is overwritten. This function does not return until the file has been completely created. (It may of course throw some kind of I/O exception instead.)

fn_list :: ((Integer, Integer) -> (Word8, Word8, Word8)) -> (Integer, Integer) -> [(Word8, Word8, Word8)]Source

Helper function: Given a function from pixel coordinates to pixel colour, produce a list of pixel data ready to feed to one of the other PPM functions.