bitmap-0.0.1: A library for handling and manipulating bitmaps.Source codeContentsIndex
Data.Bitmap.Pure
Contents
Creating bitmaps
Mapping over bitmaps
Cropping and extending
Manipulating channels
Bilinear resampling
Blending
Gamma correction
Conversion to ByteString
Synopsis
module Data.Bitmap.Base
emptyBitmap :: forall t. PixelComponent t => Size -> NChn -> Maybe Alignment -> Bitmap t
createSingleChannelBitmap :: forall t. PixelComponent t => Size -> Maybe Alignment -> (Int -> Int -> t) -> Bitmap t
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
combineChannels :: forall t. 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
bitmapToByteString :: PixelComponent t => Bitmap t -> ByteString
Documentation
module Data.Bitmap.Base
Creating bitmaps
emptyBitmapSource
:: forall t . PixelComponent t
=> Size(width,height)
-> NChnnumber of channels (components/pixel)
-> Maybe Alignmentthe 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.
createSingleChannelBitmapSource
:: forall t . PixelComponent t
=> Size(width,height)
-> Maybe Alignmentthe row alignment of the new image
-> Int -> Int -> tthe function used to create the bitmap
-> Bitmap t
Creates a single channel bitmap from a function. This is probably a bit slow.
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
copySubImageSource
:: PixelComponent t
=> Bitmap tsource image
-> Offsetsource rectangle offset
-> Sizesource rectangle size
-> Bitmap t
Copies a subrectangle of the source image into a new image.
copySubImage'Source
:: PixelComponent t
=> Bitmap tsource image
-> Offsetsource rectangle offset
-> Sizesource rectangle size
-> Sizetarget image size
-> Offsettarget rectangle offset
-> Bitmap t
Copy into a new "black" bitmap; common generalization of crop and extend.
Manipulating channels
combineChannels :: forall t. PixelComponent t => [Bitmap t] -> Maybe Alignment -> Bitmap tSource
extractChannels :: PixelComponent t => Bitmap t -> Maybe Alignment -> [Bitmap t]Source
extractSingleChannelSource
:: PixelComponent t
=> Bitmap tsource image
-> Maybe Alignmenttarget image row alignment
-> Intsource channel index
-> Bitmap t
Bilinear resampling
bilinearResampleSource
:: PixelComponent t
=> Bitmap tsource image
-> Sizetarget image size
-> Maybe Alignmenttarget image row alignment
-> Bitmap t
bilinearResampleChannelSource
:: PixelComponent t
=> Bitmap tsource image
-> Intsource channel indexe
-> Sizetarget image size
-> Maybe Alignmenttarget image row alignment
-> Bitmap t
Blending
blendBitmapsSource
:: PixelComponent t
=> Floatweight 1
-> Floatweight 2
-> Bitmap tsource image 1
-> Bitmap tsource image 2
-> Maybe Alignmenttarget 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.
blendChannelsSource
:: PixelComponent t
=> Floatweight 1
-> Floatweight 2
-> Bitmap tsource image 1
-> Intchannel index 1
-> Bitmap tsource image 2
-> Intchannel index 2
-> Maybe Alignmenttarget alignment
-> Bitmap t
Gamma correction
powerlawGammaCorrectionSource
:: PixelComponent t
=> Floatgamma
-> Bitmap tsource image
-> Maybe Alignmenttarget 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.
powerlawGammaCorrectionChannelSource
:: PixelComponent t
=> Floatgamma
-> Bitmap tsource image
-> Intsource channel indexe
-> Maybe Alignmenttarget image row alignment
-> Bitmap t
Conversion to ByteString
bitmapToByteString :: PixelComponent t => Bitmap t -> ByteStringSource
Note that the data is shared; and also that the resulting ByteString is encoded using the host machine's endianness.
Produced by Haddock version 2.4.1