Safe Haskell | Safe-Infered |
---|
The pure, inmutable API.
- module Data.Bitmap.Base
- emptyBitmap :: PixelComponent t => Size -> NChn -> Maybe Alignment -> Bitmap t
- cloneBitmap :: PixelComponent t => Bitmap t -> Maybe Alignment -> Bitmap t
- emptyCloneBitmap :: PixelComponent t => Bitmap t -> Maybe Alignment -> Bitmap t
- createSingleChannelBitmap :: PixelComponent t => Size -> Maybe Alignment -> (Int -> Int -> t) -> Bitmap t
- bitmapFromForeignPtrUnsafe :: PixelComponent t => Size -> NChn -> Alignment -> Padding -> ForeignPtr t -> Bitmap t
- withBitmap :: PixelComponent t => Bitmap t -> (Size -> NChn -> Padding -> Ptr t -> IO a) -> IO a
- componentMap :: PixelComponent s => (s -> s) -> Bitmap s -> Bitmap s
- componentMap' :: (PixelComponent s, PixelComponent t) => (s -> t) -> Bitmap s -> Maybe Alignment -> Bitmap t
- copySubImage :: PixelComponent t => Bitmap t -> Offset -> Size -> Bitmap t
- copySubImage' :: PixelComponent t => Bitmap t -> Offset -> Size -> Size -> Offset -> Bitmap t
- flipBitmap :: PixelComponent t => Bitmap t -> Maybe Alignment -> Bitmap t
- mirrorBitmap :: PixelComponent t => Bitmap t -> Maybe Alignment -> Bitmap t
- castBitmap :: (PixelComponent s, PixelComponent t) => Bitmap s -> Maybe Alignment -> 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
- bilinearResample :: PixelComponent t => Bitmap t -> Size -> Maybe Alignment -> Bitmap t
- bilinearResampleChannel :: PixelComponent t => Bitmap t -> Int -> Size -> Maybe Alignment -> Bitmap t
- blendBitmaps :: PixelComponent t => Float -> Float -> Bitmap t -> Bitmap t -> Maybe Alignment -> Bitmap t
- blendChannels :: PixelComponent t => Float -> Float -> Bitmap t -> Int -> Bitmap t -> Int -> Maybe Alignment -> Bitmap t
- powerlawGammaCorrection :: PixelComponent t => Float -> Bitmap t -> Maybe Alignment -> Bitmap t
- powerlawGammaCorrectionChannel :: PixelComponent t => Float -> Bitmap t -> Int -> Maybe Alignment -> Bitmap t
Documentation
module Data.Bitmap.Base
Creating bitmaps
:: PixelComponent t | |
=> Size | (width,height) |
-> NChn | number of channels (components/pixel) |
-> Maybe Alignment | the row alignment of the new image |
-> Bitmap t |
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.
:: PixelComponent t | |
=> Bitmap t | source image |
-> Maybe Alignment | target alignment |
-> Bitmap t |
Clones a bitmap. The only effect of this in the pure setting should be that the alignment/padding can change. You shouldn't normally use this function.
:: PixelComponent t | |
=> Bitmap t | source (only dimensions and such is used) |
-> Maybe Alignment | target alignment |
-> Bitmap t | new empty bitmap |
Creates an empty bitmap with the same properties as the source.
createSingleChannelBitmapSource
:: PixelComponent t | |
=> Size | (width,height) |
-> Maybe Alignment | the row alignment of the new image |
-> (Int -> Int -> t) | the function used to create the bitmap |
-> Bitmap t |
Creates a single channel bitmap from a function. This is probably a bit slow.
bitmapFromForeignPtrUnsafe :: PixelComponent t => Size -> NChn -> Alignment -> Padding -> ForeignPtr t -> Bitmap tSource
Using bitmaps
withBitmap :: PixelComponent t => Bitmap t -> (Size -> NChn -> Padding -> Ptr t -> IO a) -> IO aSource
withBitmap bitmap $ \(w,h) nchn padding ptr -> ...
Mapping over bitmaps
componentMap :: PixelComponent s => (s -> s) -> Bitmap s -> Bitmap sSource
Warning: this is probably slow.
componentMap' :: (PixelComponent s, PixelComponent t) => (s -> t) -> Bitmap s -> Maybe Alignment -> Bitmap tSource
Warning: this is probably slow.
Cropping and extending
:: PixelComponent t | |
=> Bitmap t | source image |
-> Offset | source rectangle offset |
-> Size | source rectangle size |
-> Bitmap t |
Copies a subrectangle of the source image into a new image.
:: PixelComponent t | |
=> Bitmap t | source image |
-> Offset | source rectangle offset |
-> Size | source rectangle size |
-> Size | target image size |
-> Offset | target rectangle offset |
-> Bitmap t |
Copy into a new "black" bitmap; common generalization of crop and extend.
Flipping and mirroring
flipBitmap :: PixelComponent t => Bitmap t -> Maybe Alignment -> Bitmap tSource
Flips the bitmap vertically.
mirrorBitmap :: PixelComponent t => Bitmap t -> Maybe Alignment -> Bitmap tSource
Flips the bitmap horizontally.
Casting
:: (PixelComponent s, PixelComponent t) | |
=> Bitmap s | source image |
-> Maybe Alignment | target image row alignment |
-> Bitmap t |
Converts between different component types.
Manipulating channels
combineChannels :: PixelComponent t => [Bitmap t] -> Maybe Alignment -> Bitmap tSource
extractChannels :: PixelComponent t => Bitmap t -> Maybe Alignment -> [Bitmap t]Source
Bilinear resampling
Blending
:: PixelComponent t | |
=> Float | weight 1 |
-> Float | weight 2 |
-> Bitmap t | source image 1 |
-> Bitmap t | source image 2 |
-> Maybe Alignment | target alignment |
-> Bitmap t |
Blends two bitmaps with the given weights; that is, the result is the specified linear combination. If the values are outside the allowed range (this can happen with the Word8, Word16, Word32 types and weights whose sum is bigger than 1, or with a negative weight), then they are clipped. The clipping does not happen with the Float component type.
Gamma correction
:: PixelComponent t | |
=> Float | gamma |
-> Bitmap t | source image |
-> Maybe Alignment | target image row alignment |
-> Bitmap t |
This is equivalent to componentMap (c -> c^gamma)
, except that
(^)
is defined only for integral exponents; but should be faster anyway.