ContentsIndex
Graphics.Plot.BMP
Description
Implements a loader for BMP files of uncompressed 24Bit RGB format. Trying to load any other format will cause errors to be thrown.
Synopsis
data FileHeader = FileHeader {
fileType :: Word16
fileSize :: Word32
fileReserved1 :: Word16
fileReserved2 :: Word16
fileOffset :: Word32
}
data ImageHeader = ImageHeader {
imageSize :: Word32
imageWidth :: Word32
imageHeight :: Word32
imagePlanes :: Word16
imageBitCount :: Word16
imageCompression :: Word32
imageSizeImage :: Word32
imagePelsPerMeterX :: Word32
imagePelsPerMeterY :: Word32
imageClrUsed :: Word32
imageClrImportant :: Word32
}
imageHeaderSize :: Int
fileHeaderSize :: Int
peekFileHeader :: Ptr Word8 -> IO FileHeader
peekImageHeader :: Ptr Word8 -> IO ImageHeader
convertImage :: (?transColor :: (Word8, Word8, Word8)) -> (?ptrDest :: Ptr Word8) -> (?ptrSrc :: Ptr Word8) -> (?width :: Int) -> (?height :: Int) -> (?slackPerLine :: Int) -> Int -> Int -> Int -> Int -> IO ()
peekLSB32 :: Ptr Word8 -> IO Word32
peekLSB16 :: Ptr Word8 -> IO Word16
loadBMP24 :: (Word8, Word8, Word8) -> FilePath -> IO (FileHeader, ImageHeader, Ptr Word8)
Documentation
data FileHeader
BMP File Header.
Constructors
FileHeader
fileType :: Word16+0. magic bytes, 0x42 0x4d.
fileSize :: Word32+2. size of the file in bytes.
fileReserved1 :: Word16+6. unused, must be zero.
fileReserved2 :: Word16+8. unused, must be zero.
fileOffset :: Word32+10. offset in bytes to start of pixel data.
show/hide Instances
data ImageHeader
BMP Image header.
Constructors
ImageHeader
imageSize :: Word32+0. size of the image header, in bytes.
imageWidth :: Word32+4. width of the image, in pixels.
imageHeight :: Word32+8. height of the image, in pixels.
imagePlanes :: Word16+12. number of color planes.
imageBitCount :: Word16+14. number of bits per pixel.
imageCompression :: Word32+16. image compression, 0 = uncompressed.
imageSizeImage :: Word32+20. size of image, may be 0 for uncompressed.
imagePelsPerMeterX :: Word32+24. prefered resolution in pixels per meter.
imagePelsPerMeterY :: Word32+28.
imageClrUsed :: Word32+32. number of color entries that are used
imageClrImportant :: Word32+36. number of significant colors
show/hide Instances
imageHeaderSize :: Int
Length of the BMP image header, in bytes.
fileHeaderSize :: Int
Length of the BMP file header, in bytes.
peekFileHeader :: Ptr Word8 -> IO FileHeader
Marshals a BMP file header from raw data.
peekImageHeader :: Ptr Word8 -> IO ImageHeader
Marshals a BMP image header from raw data.
convertImage
:: (?transColor :: (Word8, Word8, Word8))Transparency color.
-> (?ptrDest :: Ptr Word8)Pointer to destination image.
-> (?ptrSrc :: Ptr Word8)Pointer to source image.
-> (?width :: Int)Width of image in pixels.
-> (?height :: Int)Height of image in pixels.
-> (?slackPerLine :: Int)Number of bytes of slack space per line.
-> IntX position in the image.
-> IntY position in the image.
-> IntOffset into source image, in bytes.
-> IntOffset into destination image, in bytes.
-> IO ()
Performs conversion between 24bit RGB and 32bit RGBA.
peekLSB32 :: Ptr Word8 -> IO Word32
Loads and converts a 32bit LSB word to machine representation.
peekLSB16 :: Ptr Word8 -> IO Word16
Loads and converts a 16bit LSB word to machine representation.
loadBMP24
:: (Word8, Word8, Word8)The RGB color to treat as transparent. If a pixel in the BMP file has this color then the corresponding pixel in the loaded image with have an alpha value of 0. All other pixels in the loaded image will have an alpha of 1.
-> FilePathPath to the image file.
-> IO (FileHeader, ImageHeader, Ptr Word8)
Loads a BMP file in uncompressed 24bit RGB format. The resulting data is in uncompressed 32bit RGBA format.
Produced by Haddock version 0.7