massiv-io 0.1.1.0 → 0.1.2.0
raw patch · 11 files changed
+70/−153 lines, 11 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Graphics.ColorSpace: toListPx :: ColorSpace cs e => Pixel cs e -> [e]
+ Graphics.ColorSpace: eFromDouble :: Elevator e => Double -> e
+ Graphics.ColorSpace: eToDouble :: Elevator e => e -> Double
+ Graphics.ColorSpace: eToFloat :: Elevator e => e -> Float
+ Graphics.ColorSpace: eToWord16 :: Elevator e => e -> Word16
+ Graphics.ColorSpace: eToWord32 :: Elevator e => e -> Word32
+ Graphics.ColorSpace: eToWord64 :: Elevator e => e -> Word64
+ Graphics.ColorSpace: eToWord8 :: Elevator e => e -> Word8
- Graphics.ColorSpace: class (Eq cs, Enum cs, Show cs, Bounded cs, Typeable cs, Eq (Pixel cs e), Unbox (Components cs e), Storable (Pixel cs e), Elevator e) => ColorSpace cs e where {
+ Graphics.ColorSpace: class (Eq cs, Enum cs, Show cs, Bounded cs, Typeable cs, Functor (Pixel cs), Applicative (Pixel cs), Foldable (Pixel cs), Eq (Pixel cs e), Unbox (Components cs e), Storable (Pixel cs e), Elevator e) => ColorSpace cs e where {
- Graphics.ColorSpace.Complex: (+:) :: Applicative (Pixel cs) => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e)
+ Graphics.ColorSpace.Complex: (+:) :: ColorSpace cs e => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e)
- Graphics.ColorSpace.Complex: cis :: (Applicative (Pixel cs), RealFloat e) => Pixel cs e -> Pixel cs (Complex e)
+ Graphics.ColorSpace.Complex: cis :: (ColorSpace cs e, RealFloat e) => Pixel cs e -> Pixel cs (Complex e)
- Graphics.ColorSpace.Complex: conjugate :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs (Complex e)
+ Graphics.ColorSpace.Complex: conjugate :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs (Complex e)
- Graphics.ColorSpace.Complex: imagPart :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
+ Graphics.ColorSpace.Complex: imagPart :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
- Graphics.ColorSpace.Complex: magnitude :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
+ Graphics.ColorSpace.Complex: magnitude :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
- Graphics.ColorSpace.Complex: mkPolar :: (Applicative (Pixel cs), RealFloat e) => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e)
+ Graphics.ColorSpace.Complex: mkPolar :: (ColorSpace cs e, RealFloat e) => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e)
- Graphics.ColorSpace.Complex: phase :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
+ Graphics.ColorSpace.Complex: phase :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
- Graphics.ColorSpace.Complex: polar :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> (Pixel cs e, Pixel cs e)
+ Graphics.ColorSpace.Complex: polar :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> (Pixel cs e, Pixel cs e)
- Graphics.ColorSpace.Complex: realPart :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
+ Graphics.ColorSpace.Complex: realPart :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e
Files
- massiv-io.cabal +1/−1
- src/Graphics/ColorSpace.hs +3/−3
- src/Graphics/ColorSpace/Binary.hs +9/−8
- src/Graphics/ColorSpace/CMYK.hs +0/−15
- src/Graphics/ColorSpace/Complex.hs +10/−10
- src/Graphics/ColorSpace/HSI.hs +0/−15
- src/Graphics/ColorSpace/Internal.hs +45/−38
- src/Graphics/ColorSpace/RGB.hs +0/−18
- src/Graphics/ColorSpace/X.hs +2/−11
- src/Graphics/ColorSpace/Y.hs +0/−17
- src/Graphics/ColorSpace/YCbCr.hs +0/−17
massiv-io.cabal view
@@ -1,5 +1,5 @@ name: massiv-io-version: 0.1.1.0+version: 0.1.2.0 synopsis: Import/export of Image files into massiv Arrays description: This package contains functionality for import/export of arrays into the real world. For now it only has the ability to read/write
src/Graphics/ColorSpace.hs view
@@ -111,7 +111,7 @@ X(..), -- * Precision -- ** Pixel- Elevator,+ Elevator(..), toWord8, toWord16, toWord32,@@ -270,11 +270,11 @@ instance ToRGB X Bit where- toPixelRGB (PixelX b) = promote $ eToDouble b+ toPixelRGB (PixelX b) = pure $ eToDouble b {-# INLINE toPixelRGB #-} instance Elevator e => ToRGB Y e where- toPixelRGB (PixelY g) = promote $ eToDouble g+ toPixelRGB (PixelY g) = pure $ eToDouble g {-# INLINE toPixelRGB #-} instance Elevator e => ToRGB YA e where
src/Graphics/ColorSpace/Binary.hs view
@@ -18,6 +18,7 @@ Bit(..), on, off, isOn, isOff, fromBool, zero, one, bit2bool, bool2bit, toNum, fromNum ) where +import Control.Applicative import Control.Monad import Data.Bits import Data.Typeable (Typeable)@@ -85,21 +86,21 @@ instance Bits (Pixel X Bit) where- (.&.) = liftPx2 (.&.)+ (.&.) = liftA2 (.&.) {-# INLINE (.&.) #-}- (.|.) = liftPx2 (.|.)+ (.|.) = liftA2 (.|.) {-# INLINE (.|.) #-}- xor = liftPx2 xor+ xor = liftA2 xor {-# INLINE xor #-}- complement = liftPx complement+ complement = liftA complement {-# INLINE complement #-}- shift !b !n = liftPx (`shift` n) b+ shift !b !n = liftA (`shift` n) b {-# INLINE shift #-}- rotate !b !n = liftPx (`rotate` n) b+ rotate !b !n = liftA (`rotate` n) b {-# INLINE rotate #-}- zeroBits = promote zeroBits+ zeroBits = pure zeroBits {-# INLINE zeroBits #-}- bit = promote . bit+ bit = pure . bit {-# INLINE bit #-} testBit (PixelX (Bit 1)) 0 = True testBit _ _ = False
src/Graphics/ColorSpace/CMYK.hs view
@@ -17,7 +17,6 @@ CMYK(..), CMYKA(..), Pixel(..) ) where -import Control.Applicative import Data.Foldable import Data.Typeable (Typeable) import Foreign.Ptr@@ -50,8 +49,6 @@ {-# INLINE fromComponents #-} toComponents (PixelCMYK c m y k) = (c, m, y, k) {-# INLINE toComponents #-}- promote !e = PixelCMYK e e e e- {-# INLINE promote #-} getPxC (PixelCMYK c _ _ _) CyanCMYK = c getPxC (PixelCMYK _ m _ _) MagCMYK = m getPxC (PixelCMYK _ _ y _) YelCMYK = y@@ -65,10 +62,6 @@ mapPxC f (PixelCMYK c m y k) = PixelCMYK (f CyanCMYK c) (f MagCMYK m) (f YelCMYK y) (f KeyCMYK k) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-} foldlPx = foldl' {-# INLINE foldlPx #-} foldlPx2 f !z (PixelCMYK c1 m1 y1 k1) (PixelCMYK c2 m2 y2 k2) =@@ -144,8 +137,6 @@ {-# INLINE fromComponents #-} toComponents (PixelCMYKA c m y k a) = (c, m, y, k, a) {-# INLINE toComponents #-}- promote !e = PixelCMYKA e e e e e- {-# INLINE promote #-} getPxC (PixelCMYKA c _ _ _ _) CyanCMYKA = c getPxC (PixelCMYKA _ m _ _ _) MagCMYKA = m getPxC (PixelCMYKA _ _ y _ _) YelCMYKA = y@@ -161,12 +152,6 @@ mapPxC f (PixelCMYKA c m y k a) = PixelCMYKA (f CyanCMYKA c) (f MagCMYKA m) (f YelCMYKA y) (f KeyCMYKA k) (f AlphaCMYKA a) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelCMYKA c1 m1 y1 k1 a1) (PixelCMYKA c2 m2 y2 k2 a2) = f (f (f (f (f z c1 c2) m1 m2) y1 y2) k1 k2) a1 a2 {-# INLINE foldlPx2 #-}
src/Graphics/ColorSpace/Complex.hs view
@@ -6,7 +6,7 @@ #endif -- | -- Module : Graphics.ColorSpace.Complex--- Copyright : (c) Alexey Kuleshevich 2016+-- Copyright : (c) Alexey Kuleshevich 2016-2018 -- License : BSD3 -- Maintainer : Alexey Kuleshevich <lehins@yandex.ru> -- Stability : experimental@@ -34,51 +34,51 @@ -- -- @ PixelRGB 4 8 6 '+:' PixelRGB 7 1 1 __==__ PixelRGB (4 ':+' 7) (8 ':+' 1) (6 ':+' 1) @ ---(+:) :: Applicative (Pixel cs) => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e)+(+:) :: ColorSpace cs e => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e) (+:) = liftA2 (:+) {-# INLINE (+:) #-} -- | Extracts the real part of a complex pixel.-realPart :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e+realPart :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e realPart = liftA C.realPart {-# INLINE realPart #-} -- | Extracts the imaginary part of a complex pixel.-imagPart :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e+imagPart :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e imagPart = liftA C.imagPart {-# INLINE imagPart #-} -- | Form a complex pixel from polar components of magnitude and phase.-mkPolar :: (Applicative (Pixel cs), RealFloat e) =>+mkPolar :: (ColorSpace cs e, RealFloat e) => Pixel cs e -> Pixel cs e -> Pixel cs (Complex e) mkPolar = liftA2 C.mkPolar {-# INLINE mkPolar #-} -- | @'cis' t@ is a complex pixel with magnitude 1 and phase t (modulo @2*'pi'@).-cis :: (Applicative (Pixel cs), RealFloat e) => Pixel cs e -> Pixel cs (Complex e)+cis :: (ColorSpace cs e, RealFloat e) => Pixel cs e -> Pixel cs (Complex e) cis = liftA C.cis {-# INLINE cis #-} -- | The function @'polar'@ takes a complex pixel and returns a (magnitude, phase) -- pair of pixels in canonical form: the magnitude is nonnegative, and the phase -- in the range @(-'pi', 'pi']@; if the magnitude is zero, then so is the phase.-polar :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> (Pixel cs e, Pixel cs e)+polar :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> (Pixel cs e, Pixel cs e) polar !zPx = (magnitude zPx, phase zPx) {-# INLINE polar #-} -- | The nonnegative magnitude of a complex pixel.-magnitude :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e+magnitude :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e magnitude = liftA C.magnitude {-# INLINE magnitude #-} -- | The phase of a complex pixel, in the range @(-'pi', 'pi']@. If the -- magnitude is zero, then so is the phase.-phase :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs e+phase :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs e phase = liftA C.phase {-# INLINE phase #-} -- | The conjugate of a complex pixel.-conjugate :: (Applicative (Pixel cs), RealFloat e) => Pixel cs (Complex e) -> Pixel cs (Complex e)+conjugate :: (ColorSpace cs e, RealFloat e) => Pixel cs (Complex e) -> Pixel cs (Complex e) conjugate = liftA C.conjugate {-# INLINE conjugate #-}
src/Graphics/ColorSpace/HSI.hs view
@@ -17,7 +17,6 @@ HSI(..), HSIA(..), Pixel(..) ) where -import Control.Applicative import Data.Foldable import Data.Typeable (Typeable) import Foreign.Ptr@@ -49,8 +48,6 @@ {-# INLINE toComponents #-} fromComponents !(h, s, i) = PixelHSI h s i {-# INLINE fromComponents #-}- promote = pure- {-# INLINE promote #-} getPxC (PixelHSI h _ _) HueHSI = h getPxC (PixelHSI _ s _) SatHSI = s getPxC (PixelHSI _ _ i) IntHSI = i@@ -61,10 +58,6 @@ {-# INLINE setPxC #-} mapPxC f (PixelHSI h s i) = PixelHSI (f HueHSI h) (f SatHSI s) (f IntHSI i) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-} foldlPx = foldl' {-# INLINE foldlPx #-} foldlPx2 f !z (PixelHSI h1 s1 i1) (PixelHSI h2 s2 i2) =@@ -135,8 +128,6 @@ {-# INLINE toComponents #-} fromComponents !(h, s, i, a) = PixelHSIA h s i a {-# INLINE fromComponents #-}- promote = pure- {-# INLINE promote #-} getPxC (PixelHSIA h _ _ _) HueHSIA = h getPxC (PixelHSIA _ s _ _) SatHSIA = s getPxC (PixelHSIA _ _ i _) IntHSIA = i@@ -150,12 +141,6 @@ mapPxC f (PixelHSIA h s i a) = PixelHSIA (f HueHSIA h) (f SatHSIA s) (f IntHSIA i) (f AlphaHSIA a) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelHSIA h1 s1 i1 a1) (PixelHSIA h2 s2 i2 a2) = f (f (f (f z h1 h2) s1 s2) i1 i2) a1 a2 {-# INLINE foldlPx2 #-}
src/Graphics/ColorSpace/Internal.hs view
@@ -18,11 +18,11 @@ , module Graphics.ColorSpace.Elevator ) where +import Control.Applicative import Control.DeepSeq (NFData (rnf), deepseq) import Control.Monad (liftM) import Data.Default import Data.Foldable-import Data.Maybe (fromMaybe) import Data.Typeable import qualified Data.Vector.Generic as V import qualified Data.Vector.Generic.Mutable as VM@@ -36,7 +36,8 @@ class (Eq cs, Enum cs, Show cs, Bounded cs, Typeable cs,- Eq (Pixel cs e), VU.Unbox (Components cs e), VS.Storable (Pixel cs e), Elevator e)+ Functor (Pixel cs), Applicative (Pixel cs), Foldable (Pixel cs),+ Eq (Pixel cs e), VU.Unbox (Components cs e), VS.Storable (Pixel cs e), Elevator e) => ColorSpace cs e where type Components cs e@@ -50,6 +51,8 @@ -- | Construt a Pixel by replicating the same value across all of the components. promote :: e -> Pixel cs e+ promote = pure+ {-# INLINE promote #-} -- | Retrieve Pixel's component value getPxC :: Pixel cs e -> cs -> e@@ -60,36 +63,40 @@ -- | Map a channel aware function over all Pixel's components. mapPxC :: (cs -> e -> e) -> Pixel cs e -> Pixel cs e + -- | Left fold on two pixels a the same time. If accumulator is nutrual to the folding funciton+ -- then it's equivalent to @foldlPx2 f acc px1 px2 == foldl' acc (liftA2 (f acc) px1 px2)@+ foldlPx2 :: (b -> e -> e -> b) -> b -> Pixel cs e -> Pixel cs e -> b+ -- | Map a function over all Pixel's componenets. liftPx :: (e -> e) -> Pixel cs e -> Pixel cs e+ liftPx = fmap+ {-# INLINE liftPx #-} -- | Zip two Pixels with a function. liftPx2 :: (e -> e -> e) -> Pixel cs e -> Pixel cs e -> Pixel cs e-- -- | Left fold on two pixels a the same time.- foldlPx2 :: (b -> e -> e -> b) -> b -> Pixel cs e -> Pixel cs e -> b+ liftPx2 = liftA2+ {-# INLINE liftPx2 #-} -- | Right fold over all Pixel's components. foldrPx :: (e -> b -> b) -> b -> Pixel cs e -> b- foldrPx f !z0 !xs = foldlPx f' id xs z0- where f' k x !z = k $! f x z+ foldrPx = foldr'+ {-# INLINE foldrPx #-} -- | Left strict fold over all Pixel's components. foldlPx :: (b -> e -> b) -> b -> Pixel cs e -> b- foldlPx f !z0 !xs = foldrPx f' id xs z0- where f' x k !z = k $! f z x+ foldlPx = foldl'+ {-# INLINE foldlPx #-} foldl1Px :: (e -> e -> e) -> Pixel cs e -> e- foldl1Px f !xs = fromMaybe (error "foldl1Px: empty Pixel")- (foldlPx mf Nothing xs)- where- mf m !y = Just (case m of- Nothing -> y- Just x -> f x y)- toListPx :: Pixel cs e -> [e]- toListPx !px = foldr' f [] (enumFrom (toEnum 0))- where f !cs !ls = getPxC px cs:ls+ foldl1Px = foldl1+ {-# INLINE foldl1Px #-} +{-# DEPRECATED liftPx "Use `fmap` from `Functor` instead" #-}+{-# DEPRECATED liftPx2 "Use `liftA2` from `Applicative` instead" #-}+{-# DEPRECATED promote "Use `pure` from `Applicative` instead" #-}+{-# DEPRECATED foldlPx "Use `foldl'` from `Foldable` instead" #-}+{-# DEPRECATED foldrPx "Use `foldr'` from `Foldable` instead" #-}+{-# DEPRECATED foldl1Px "Use `foldl1` from `Foldable` instead" #-} -- | A color space that supports transparency. class (ColorSpace (Opaque cs) e, ColorSpace cs e) => AlphaSpace cs e where@@ -118,24 +125,24 @@ instance ColorSpace cs e => Num (Pixel cs e) where- (+) = liftPx2 (+)+ (+) = liftA2 (+) {-# INLINE (+) #-}- (-) = liftPx2 (-)+ (-) = liftA2 (-) {-# INLINE (-) #-}- (*) = liftPx2 (*)+ (*) = liftA2 (*) {-# INLINE (*) #-}- abs = liftPx abs+ abs = liftA abs {-# INLINE abs #-}- signum = liftPx signum+ signum = liftA signum {-# INLINE signum #-} fromInteger = promote . fromInteger {-# INLINE fromInteger #-} instance (ColorSpace cs e, Fractional e) => Fractional (Pixel cs e) where- (/) = liftPx2 (/)+ (/) = liftA2 (/) {-# INLINE (/) #-}- recip = liftPx recip+ recip = liftA recip {-# INLINE recip #-} fromRational = promote . fromRational {-# INLINE fromRational #-}@@ -144,29 +151,29 @@ instance (ColorSpace cs e, Floating e) => Floating (Pixel cs e) where pi = promote pi {-# INLINE pi #-}- exp = liftPx exp+ exp = liftA exp {-# INLINE exp #-}- log = liftPx log+ log = liftA log {-# INLINE log #-}- sin = liftPx sin+ sin = liftA sin {-# INLINE sin #-}- cos = liftPx cos+ cos = liftA cos {-# INLINE cos #-}- asin = liftPx asin+ asin = liftA asin {-# INLINE asin #-}- atan = liftPx atan+ atan = liftA atan {-# INLINE atan #-}- acos = liftPx acos+ acos = liftA acos {-# INLINE acos #-}- sinh = liftPx sinh+ sinh = liftA sinh {-# INLINE sinh #-}- cosh = liftPx cosh+ cosh = liftA cosh {-# INLINE cosh #-}- asinh = liftPx asinh+ asinh = liftA asinh {-# INLINE asinh #-}- atanh = liftPx atanh+ atanh = liftA atanh {-# INLINE atanh #-}- acosh = liftPx acosh+ acosh = liftA acosh {-# INLINE acosh #-} instance (ColorSpace cs e, Bounded e) => Bounded (Pixel cs e) where@@ -177,7 +184,7 @@ instance (ColorSpace cs e, NFData e) => NFData (Pixel cs e) where - rnf = foldrPx deepseq ()+ rnf = foldr' deepseq () {-# INLINE rnf #-}
src/Graphics/ColorSpace/RGB.hs view
@@ -18,10 +18,8 @@ ) where import Prelude hiding (map)-import Control.Applicative import Foreign.Ptr import Foreign.Storable-import Data.Foldable import Data.Typeable (Typeable) import Graphics.ColorSpace.Internal @@ -48,8 +46,6 @@ {-# INLINE toComponents #-} fromComponents !(r, g, b) = PixelRGB r g b {-# INLINE fromComponents #-}- promote = pure- {-# INLINE promote #-} getPxC (PixelRGB r _ _) RedRGB = r getPxC (PixelRGB _ g _) GreenRGB = g getPxC (PixelRGB _ _ b) BlueRGB = b@@ -60,12 +56,6 @@ {-# INLINE setPxC #-} mapPxC f (PixelRGB r g b) = PixelRGB (f RedRGB r) (f GreenRGB g) (f BlueRGB b) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelRGB r1 g1 b1) (PixelRGB r2 g2 b2) = f (f (f z r1 r2) g1 g2) b1 b2 {-# INLINE foldlPx2 #-}@@ -129,8 +119,6 @@ {-# INLINE toComponents #-} fromComponents !(r, g, b, a) = PixelRGBA r g b a {-# INLINE fromComponents #-}- promote = pure- {-# INLINE promote #-} getPxC (PixelRGBA r _ _ _) RedRGBA = r getPxC (PixelRGBA _ g _ _) GreenRGBA = g getPxC (PixelRGBA _ _ b _) BlueRGBA = b@@ -144,12 +132,6 @@ mapPxC f (PixelRGBA r g b a) = PixelRGBA (f RedRGBA r) (f GreenRGBA g) (f BlueRGBA b) (f AlphaRGBA a) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelRGBA r1 g1 b1 a1) (PixelRGBA r2 g2 b2 a2) = f (f (f (f z r1 r2) g1 g2) b1 b2) a1 a2 {-# INLINE foldlPx2 #-}
src/Graphics/ColorSpace/X.hs view
@@ -20,7 +20,6 @@ , fromPixelsX ) where -import Control.Applicative import Data.Foldable import Data.Typeable (Typeable) import Foreign.Ptr@@ -46,8 +45,6 @@ instance Elevator e => ColorSpace X e where type Components X e = e - promote = PixelX- {-# INLINE promote #-} fromComponents = PixelX {-# INLINE fromComponents #-} toComponents (PixelX g) = g@@ -58,12 +55,6 @@ {-# INLINE setPxC #-} mapPxC f (PixelX g) = PixelX (f X g) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelX g1) (PixelX g2) = f z g1 g2 {-# INLINE foldlPx2 #-} @@ -118,7 +109,7 @@ -- [<X:(4)>,<X:(5)>,<X:(6)>] -- toPixelsX :: ColorSpace cs e => Pixel cs e -> [Pixel X e]-toPixelsX = foldrPx ((:) . PixelX) []+toPixelsX = fmap PixelX . toList -- | Combine a list of `X` pixels into a Pixel with a specified channel -- order. Not the most efficient way to construct a pixel, but might prove@@ -130,7 +121,7 @@ -- <RGB:(4.0|5.0|6.0)> -- fromPixelsX :: ColorSpace cs e => [(cs, Pixel X e)] -> Pixel cs e-fromPixelsX = foldl' f (promote 0) where+fromPixelsX = foldl' f (pure 0) where f !px (c, PixelX x) = setPxC px c x
src/Graphics/ColorSpace/Y.hs view
@@ -17,7 +17,6 @@ Y(..), YA(..), Pixel(..) ) where -import Control.Applicative import Data.Foldable import Data.Typeable (Typeable) import Foreign.Ptr@@ -40,8 +39,6 @@ instance Elevator e => ColorSpace Y e where type Components Y e = e- promote = PixelY- {-# INLINE promote #-} fromComponents = PixelY {-# INLINE fromComponents #-} toComponents (PixelY y) = y@@ -52,12 +49,6 @@ {-# INLINE setPxC #-} mapPxC f (PixelY y) = PixelY (f LumaY y) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelY y1) (PixelY y2) = f z y1 y2 {-# INLINE foldlPx2 #-} @@ -124,8 +115,6 @@ instance Elevator e => ColorSpace YA e where type Components YA e = (e, e)- promote e = PixelYA e e- {-# INLINE promote #-} fromComponents (y, a) = PixelYA y a {-# INLINE fromComponents #-} toComponents (PixelYA y a) = (y, a)@@ -138,12 +127,6 @@ {-# INLINE setPxC #-} mapPxC f (PixelYA y a) = PixelYA (f LumaYA y) (f AlphaYA a) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelYA y1 a1) (PixelYA y2 a2) = f (f z y1 y2) a1 a2 {-# INLINE foldlPx2 #-}
src/Graphics/ColorSpace/YCbCr.hs view
@@ -17,7 +17,6 @@ YCbCr(..), YCbCrA(..), Pixel(..) ) where -import Control.Applicative import Data.Foldable import Data.Typeable (Typeable) import Foreign.Ptr@@ -46,8 +45,6 @@ instance Elevator e => ColorSpace YCbCr e where type Components YCbCr e = (e, e, e) - promote !e = PixelYCbCr e e e- {-# INLINE promote #-} fromComponents !(y, b, r) = PixelYCbCr y b r {-# INLINE fromComponents #-} toComponents (PixelYCbCr y b r) = (y, b, r)@@ -62,12 +59,6 @@ {-# INLINE setPxC #-} mapPxC f (PixelYCbCr y b r) = PixelYCbCr (f LumaYCbCr y) (f CBlueYCbCr b) (f CRedYCbCr r) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelYCbCr y1 b1 r1) (PixelYCbCr y2 b2 r2) = f (f (f z y1 y2) b1 b2) r1 r2 {-# INLINE foldlPx2 #-}@@ -133,8 +124,6 @@ instance Elevator e => ColorSpace YCbCrA e where type Components YCbCrA e = (e, e, e, e) - promote !e = PixelYCbCrA e e e e- {-# INLINE promote #-} fromComponents !(y, b, r, a) = PixelYCbCrA y b r a {-# INLINE fromComponents #-} toComponents (PixelYCbCrA y b r a) = (y, b, r, a)@@ -152,12 +141,6 @@ mapPxC f (PixelYCbCrA y b r a) = PixelYCbCrA (f LumaYCbCrA y) (f CBlueYCbCrA b) (f CRedYCbCrA r) (f AlphaYCbCrA a) {-# INLINE mapPxC #-}- liftPx = fmap- {-# INLINE liftPx #-}- liftPx2 = liftA2- {-# INLINE liftPx2 #-}- foldlPx = foldl'- {-# INLINE foldlPx #-} foldlPx2 f !z (PixelYCbCrA y1 b1 r1 a1) (PixelYCbCrA y2 b2 r2 a2) = f (f (f (f z y1 y2) b1 b2) r1 r2) a1 a2 {-# INLINE foldlPx2 #-}