Safe Haskell | None |
---|---|
Language | Haskell98 |
Data.Bitmap.Simple
Description
This is the same as the pure API, without the annoying alignment stuff. All functions use the default alignment.
Synopsis
- module Data.Bitmap.Base
- emptyBitmap :: PixelComponent t => Size -> NChn -> Bitmap t
- emptyCloneBitmap :: PixelComponent t => Bitmap t -> Bitmap t
- createSingleChannelBitmap :: PixelComponent t => Size -> (Int -> Int -> 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 -> 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 -> Bitmap t
- mirrorBitmap :: PixelComponent t => Bitmap t -> Bitmap t
- castBitmap :: (PixelComponent s, PixelComponent t) => Bitmap s -> Bitmap t
- combineChannels :: PixelComponent t => [Bitmap t] -> Bitmap t
- extractChannels :: PixelComponent t => Bitmap t -> [Bitmap t]
- extractSingleChannel :: PixelComponent t => Bitmap t -> Int -> Bitmap t
- bilinearResample :: PixelComponent t => Bitmap t -> Size -> Bitmap t
- bilinearResampleChannel :: PixelComponent t => Bitmap t -> Int -> Size -> Bitmap t
- blendBitmaps :: PixelComponent t => Float -> Float -> Bitmap t -> Bitmap t -> Bitmap t
- blendChannels :: PixelComponent t => Float -> Float -> Bitmap t -> Int -> Bitmap t -> Int -> Bitmap t
- powerlawGammaCorrection :: PixelComponent t => Float -> Bitmap t -> Bitmap t
- powerlawGammaCorrectionChannel :: PixelComponent t => Float -> Bitmap t -> Int -> Bitmap t
Documentation
module Data.Bitmap.Base
Creating bitmaps
Arguments
:: PixelComponent t | |
=> Size | (width,height) |
-> NChn | number of channels (components/pixel) |
-> Bitmap t |
A bitmap filled with zero values.
Arguments
:: PixelComponent t | |
=> Bitmap t | source (only dimensions and such is used) |
-> Bitmap t | new empty bitmap |
Creates an empty bitmap with the same properties as the source.
createSingleChannelBitmap Source #
Arguments
:: PixelComponent t | |
=> Size | (width,height) |
-> (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.
Using bitmaps
withBitmap :: PixelComponent t => Bitmap t -> (Size -> NChn -> Padding -> Ptr t -> IO a) -> IO a Source #
withBitmap bitmap $ \(w,h) nchn padding ptr -> ...
Mapping over bitmaps
componentMap :: PixelComponent s => (s -> s) -> Bitmap s -> Bitmap s Source #
Warning: this is probably slow.
componentMap' :: (PixelComponent s, PixelComponent t) => (s -> t) -> Bitmap s -> Bitmap t Source #
Warning: this is probably slow.
Cropping and extending
Arguments
:: 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.
Arguments
:: 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 -> Bitmap t Source #
Flips the bitmap vertically.
mirrorBitmap :: PixelComponent t => Bitmap t -> Bitmap t Source #
Flips the bitmap horizontally.
Casting
Arguments
:: (PixelComponent s, PixelComponent t) | |
=> Bitmap s | source image |
-> Bitmap t |
Converts between different component types.
Manipulating channels
combineChannels :: PixelComponent t => [Bitmap t] -> Bitmap t Source #
extractChannels :: PixelComponent t => Bitmap t -> [Bitmap t] Source #
Arguments
:: PixelComponent t | |
=> Bitmap t | source image |
-> Int | source channel index |
-> Bitmap t |
Bilinear resampling
Arguments
:: PixelComponent t | |
=> Bitmap t | source image |
-> Size | target image size |
-> Bitmap t |
bilinearResampleChannel Source #
Arguments
:: PixelComponent t | |
=> Bitmap t | source image |
-> Int | source channel indexe |
-> Size | target image size |
-> Bitmap t |
Blending
Arguments
:: PixelComponent t | |
=> Float | weight 1 |
-> Float | weight 2 |
-> Bitmap t | source image 1 |
-> Bitmap t | source image 2 |
-> 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
powerlawGammaCorrection Source #
Arguments
:: PixelComponent t | |
=> Float | gamma |
-> Bitmap t | source image |
-> Bitmap t |
This is equivalent to componentMap (c -> c^gamma)
, except that
(^)
is defined only for integral exponents; but should be faster anyway.
powerlawGammaCorrectionChannel Source #
Arguments
:: PixelComponent t | |
=> Float | gamma |
-> Bitmap t | source image |
-> Int | source channel indexe |
-> Bitmap t |