repa-io-2.1.0.1: Read and write Repa arrays in various formats.

Data.Array.Repa.IO.BMP

Description

Reading and writing arrays as uncompressed 24 and 32 bit Windows BMP files.

Synopsis

Documentation

readImageFromBMP :: FilePath -> IO (Either Error (Array DIM3 Word8))Source

Read a RGBA image from a BMP file. In the result, the higher two dimensions are the height and width, and the lower indexes the RGBA component of each pixel. If the BMP read has no alpha channel then alpha of the resulting pixels is set to 255. If anything goes wrong when loading the file then Error.

readComponentsFromBMP :: FilePath -> IO (Either Error (Array DIM2 Word8, Array DIM2 Word8, Array DIM2 Word8))Source

Read RGB components from a BMP file. Returns arrays of red, green and blue components, all with the same extent. If anything goes wrong when loading the file then then Error.

readComponentsListFromBMP :: FilePath -> IO (Either Error [Array DIM2 Word8])Source

Like readComponentsFromBMP, but return the components as a list.

readMatrixFromGreyscaleBMP :: FilePath -> IO (Either Error (Array DIM2 Double))Source

Read a matrix from a BMP file. Each pixel is converted to greyscale, normalised to [0..1] and used as the corresponding array element. If anything goes wrong when loading the file then Error.

writeImageToBMP :: FilePath -> Array DIM3 Word8 -> IO ()Source

Write a RGBA image to a BMP file. The higher two dimensions are the height and width of the image. The lowest dimension must have size 4, corresponding to the RGBA components of each pixel, else error.

writeComponentsToBMP :: FilePath -> Array DIM2 Word8 -> Array DIM2 Word8 -> Array DIM2 Word8 -> IO ()Source

Write RGB components to a BMP file. All arrays must have the same extent, else error.

writeComponentsListToBMP :: FilePath -> [Array DIM2 Word8] -> IO ()Source

Like writeComponentsToBMP but take the components as a list. The list must have 3 arrays, for the red, green blue components respectively, else error.

writeMatrixToGreyscaleBMP :: forall a. (Num a, Elt a, Fractional a, RealFrac a) => FilePath -> Array DIM2 a -> IO ()Source

Write a matrix to a BMP file. Negative values are discarded. Positive values are normalised to the maximum value in the matrix and used as greyscale pixels.