-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A library for handling and manipulating bitmaps. -- -- A library for handling and manipulating bitmaps (that is, rectangular -- pixel arrays). @package bitmap @version 0.0.0 module Data.Bitmap.Base class (Num t, Storable t) => PixelComponent t data PixelComponentType PctWord8 :: PixelComponentType PctWord16 :: PixelComponentType PctWord32 :: PixelComponentType PctFloat :: PixelComponentType pixelComponentType :: (PixelComponent t) => t -> PixelComponentType -- | 8-bit unsigned integer type data Word8 :: * -- | 16-bit unsigned integer type data Word16 :: * -- | 32-bit unsigned integer type data Word32 :: * type Size = (Int, Int) type Offset = (Int, Int) type NChn = Int type Alignment = Int type Padding = Int data Bitmap t -- | (width,height) bitmapSize :: Bitmap t -> Size -- | number of channels (eg. 3 for RGB) bitmapNChannels :: Bitmap t -> NChn -- | the padding of the rows, measured in bytes bitmapRowPadding :: Bitmap t -> Padding -- | the alignment of the rows (in bytes) bitmapRowAlignment :: Bitmap t -> Alignment bitmapComponentSizeInBytes :: (PixelComponent t) => Bitmap t -> Int bitmapPixelSizeInBytes :: (PixelComponent t) => Bitmap t -> Int bitmapPaddedRowSizeInBytes :: (PixelComponent t) => Bitmap t -> Int bitmapUnpaddedRowSizeInBytes :: (PixelComponent t) => Bitmap t -> Int bitmapSizeInBytes :: (PixelComponent t) => Bitmap t -> Int -- | The full, mutable API in the IO monad. module Data.Bitmap.IO -- | Note: we cannot guarantee the alignment of the memory block -- (but typically it is aligned at least to machine word boundary), but -- what we can guarantee is that the rows are properly padded. -- -- The resulting new bitmap is filled with zeros. newBitmap :: (PixelComponent t) => Size -> NChn -> Maybe Alignment -> IO (Bitmap t) newBitmapUninitialized :: (PixelComponent t) => Size -> NChn -> Maybe Alignment -> IO (Bitmap t) copyBitmapFromPtr :: (PixelComponent t) => Size -> NChn -> Padding -> Ptr t -> Maybe Alignment -> IO (Bitmap t) bitmapFromForeignPtrUnsafe :: (PixelComponent t) => Size -> NChn -> Alignment -> Padding -> ForeignPtr t -> Bitmap t -- |
--   withBitmap bitmap $ \(w,h) nchn padding ptr -> ...
--   
withBitmap :: (PixelComponent t) => Bitmap t -> (Size -> NChn -> Padding -> Ptr t -> IO a) -> IO a -- | Maps a function over each component of each pixel. Warning: this is -- slow! Use a specialized function if there is one for your task. -- -- Note: We don't do the more general (s->t) here, because then we -- would have no idea about the padding in the new bitmap. See -- componentMap' for that. componentMap :: (PixelComponent s) => (s -> s) -> Bitmap s -> IO (Bitmap s) -- | See the comments at componentMap. componentMap' :: (PixelComponent s, PixelComponent t) => (s -> t) -> Bitmap s -> Maybe Alignment -> IO (Bitmap t) componentMapInPlace :: (PixelComponent s) => (s -> s) -> Bitmap s -> IO () -- | Copies a subrectangle of the source image into a new image. copySubImage :: (PixelComponent t) => Bitmap t -> Offset -> Size -> IO (Bitmap t) -- | Copy into a new "black" bitmap; common generalization of crop and -- extend. copySubImage' :: (PixelComponent t) => Bitmap t -> Offset -> Size -> Size -> Offset -> IO (Bitmap t) -- | The source rectangle may be arbitrary, may or may not intersect the -- source image in any way. We only copy the intersection of the -- rectangle with the image. copySubImageInto :: (PixelComponent t) => Bitmap t -> Offset -> Size -> Bitmap t -> Offset -> IO () combineChannels :: (PixelComponent t) => [Bitmap t] -> Maybe Alignment -> IO (Bitmap t) extractChannels :: (PixelComponent t) => Bitmap t -> Maybe Alignment -> IO [Bitmap t] extractSingleChannel :: (PixelComponent t) => Bitmap t -> Maybe Alignment -> Int -> IO (Bitmap t) extractChannelInto :: (PixelComponent t) => Bitmap t -> Int -> Bitmap t -> Int -> IO () -- | The data is copied, not shared. copyBitmapToByteString :: (PixelComponent t) => Bitmap t -> IO ByteString -- | The data is copied, not shared. copyBitmapFromByteString :: (PixelComponent t) => ByteString -> Size -> NChn -> Padding -> IO (Bitmap t) module Data.Bitmap.Pure -- | A bitmap filled with zero values. Note: we cannot guarantee the -- alignment of the memory block (but typically it is aligned at least to -- machine word boundary), but what we can guarantee is that the -- rows are properly padded. emptyBitmap :: (PixelComponent t) => Size -> NChn -> Maybe Alignment -> Bitmap t -- | Warning: this is probably slow componentMap :: (PixelComponent s) => (s -> s) -> Bitmap s -> Bitmap s -- | Warning: this is probably slow componentMap' :: (PixelComponent s, PixelComponent t) => (s -> t) -> Bitmap s -> Maybe Alignment -> Bitmap t -- | Copies a subrectangle of the source image into a new image. copySubImage :: (PixelComponent t) => Bitmap t -> Offset -> Size -> Bitmap t -- | Copy into a new "black" bitmap; common generalization of crop and -- extend. copySubImage' :: (PixelComponent t) => Bitmap t -> Offset -> Size -> Size -> Offset -> Bitmap t combineChannels :: (PixelComponent t) => [Bitmap t] -> Maybe Alignment -> Bitmap t extractChannels :: (PixelComponent t) => Bitmap t -> Maybe Alignment -> [Bitmap t] extractSingleChannel :: (PixelComponent t) => Bitmap t -> Maybe Alignment -> Int -> Bitmap t -- | Note that the data is shared. bitmapToByteString :: (PixelComponent t) => Bitmap t -> ByteString -- | A library to handle bitmaps (uncompressed pixel rectangles). The -- smallest storage unit is 1 byte (thus bitmaps, in the literal -- sense of the word, are not supported). You may want to import this -- module qualified. -- -- Terminology: Pixels are made out of one or more "components". These -- components are also referred as "channels"; for example a color image -- could be made out of three channels, the red, green and blue one. The -- components can be unsigned bytes, words, dwords, or floats. The pixels -- are stored in horizontal order, and the channels are interleaved: That -- is, the structure of an RGB image is R0 G0 B0 R1 G1 B1 .... -- Most of the library is agnostic to the meaning of different channels. -- -- "Padding" refers to unused bytes at the end of each row. This is -- sometimes necessary because other software components want the rows -- aligned to machine word boundary, for example. -- -- The library should be relatively fast (except where noted), but -- performance is not the primary goal (thus there is no inline assembly, -- no SSE, etc). -- -- There are both pure and IO versions of the API; you shouldn't mix the -- two without taking special care. This module re-exports the pure -- interface; if you want the IO one, import Data.Bitmap.IO -- instead. module Data.Bitmap