hip 1.4.0.0 → 1.4.0.1
raw patch · 5 files changed
+47/−8 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Graphics.Image.ColorSpace: instance (GHC.Num.Num e, Graphics.Image.Interface.Elevator e, GHC.Float.RealFloat e) => Graphics.Image.Interface.Elevator (Data.Complex.Complex e)
+ Graphics.Image.IO.Formats: instance (Graphics.Image.Interface.Array arr cs e, Graphics.Image.Interface.Array arr cs (Data.Complex.Complex e), GHC.Float.RealFloat e, GHC.Base.Applicative (Graphics.Image.Interface.Pixel cs), Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs e) format) => Graphics.Image.IO.Base.Writable (Graphics.Image.Interface.Image arr cs (Data.Complex.Complex e)) format
- Graphics.Image: displayImage :: Writable (Image arr cs e) TIF => Image arr cs e -> IO ()
+ Graphics.Image: displayImage :: (Array VS cs e, Array arr cs e, Exchangable arr VS, Writable (Image VS cs e) TIF) => Image arr cs e -> IO ()
- Graphics.Image: writeImage :: Writable (Image arr cs e) OutputFormat => FilePath -> Image arr cs e -> IO ()
+ Graphics.Image: writeImage :: (Array VS cs e, Array arr cs e, Exchangable arr VS, Writable (Image VS cs e) OutputFormat) => FilePath -> Image arr cs e -> IO ()
- Graphics.Image.IO: displayImage :: Writable (Image arr cs e) TIF => Image arr cs e -> IO ()
+ Graphics.Image.IO: displayImage :: (Array VS cs e, Array arr cs e, Exchangable arr VS, Writable (Image VS cs e) TIF) => Image arr cs e -> IO ()
- Graphics.Image.IO: writeImage :: Writable (Image arr cs e) OutputFormat => FilePath -> Image arr cs e -> IO ()
+ Graphics.Image.IO: writeImage :: (Array VS cs e, Array arr cs e, Exchangable arr VS, Writable (Image VS cs e) OutputFormat) => FilePath -> Image arr cs e -> IO ()
Files
- CHANGELOG.md +7/−0
- hip.cabal +1/−1
- src/Graphics/Image/ColorSpace.hs +20/−3
- src/Graphics/Image/IO.hs +7/−4
- src/Graphics/Image/IO/Formats.hs +12/−0
CHANGELOG.md view
@@ -1,3 +1,10 @@+1.4.0.1+=======++* Fixed the ability to construct complex images by installing `Complex` into `Elevator`+* Made it possible to write complex images by concatenating real and imaginary part together.+* Fixed writing images in other representation than `VS`.+ 1.4.0.0 =======
hip.cabal view
@@ -1,5 +1,5 @@ Name: hip-Version: 1.4.0.0+Version: 1.4.0.1 License: BSD3 License-File: LICENSE Author: Alexey Kuleshevich
src/Graphics/Image/ColorSpace.hs view
@@ -1,9 +1,13 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE BangPatterns #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-}+#if __GLASGOW_HASKELL__ >= 800+ {-# OPTIONS_GHC -Wno-redundant-constraints #-}+#endif -- | -- Module : Graphics.Image.ColorSpace -- Copyright : (c) Alexey Kuleshevich 2017@@ -36,6 +40,7 @@ Word8, Word16, Word32, Word64 ) where +import qualified Data.Complex as C import Data.Word import Data.Int import GHC.Float@@ -446,6 +451,18 @@ {-# INLINE fromDouble #-} ---+instance (Num e, Elevator e, RealFloat e) => Elevator (C.Complex e) where+ toWord8 = toWord8 . C.realPart+ {-# INLINE toWord8 #-}+ toWord16 = toWord16 . C.realPart+ {-# INLINE toWord16 #-}+ toWord32 = toWord32 . C.realPart+ {-# INLINE toWord32 #-}+ toWord64 = toWord64 . C.realPart+ {-# INLINE toWord64 #-}+ toFloat = toFloat . C.realPart+ {-# INLINE toFloat #-}+ toDouble = toDouble . C.realPart+ {-# INLINE toDouble #-}+ fromDouble = (C.:+ 0) . fromDouble+ {-# INLINE fromDouble #-}
src/Graphics/Image/IO.hs view
@@ -50,6 +50,7 @@ import Graphics.Image.ColorSpace import Graphics.Image.Interface+import Graphics.Image.Interface.Vector import Graphics.Image.IO.Base import Graphics.Image.IO.Formats @@ -130,11 +131,12 @@ -- that image in 'GIF' format would save it in @RGB8@, since 'Word8' is the -- highest precision 'GIF' supports and it currently cannot be saved with -- transparency.-writeImage :: Writable (Image arr cs e) OutputFormat =>+writeImage :: (Array VS cs e, Array arr cs e,+ Exchangable arr VS, Writable (Image VS cs e) OutputFormat) => FilePath -- ^ Location where an image should be written. -> Image arr cs e -- ^ An image to write. -> IO ()-writeImage path = BL.writeFile path . encode format [] where+writeImage path = BL.writeFile path . encode format [] . exchange VS where format = fromMaybe (error ("Could not guess output format. Use 'writeImageExact' "++ "or supply a filename with supported format.")) (guessFormat path :: Maybe OutputFormat)@@ -194,10 +196,11 @@ >>> displayImage frog -}-displayImage :: Writable (Image arr cs e) TIF =>+displayImage :: (Array VS cs e, Array arr cs e,+ Exchangable arr VS, Writable (Image VS cs e) TIF) => Image arr cs e -- ^ Image to be displayed -> IO ()-displayImage = displayImageUsing defaultViewer False+displayImage = displayImageUsing defaultViewer False . exchange VS defaultViewer :: ExternalViewer
src/Graphics/Image/IO/Formats.hs view
@@ -1,3 +1,4 @@+{-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -18,7 +19,10 @@ Readable(..), Writable(..), ImageFormat(..), ) where +import Graphics.Image.ColorSpace import Graphics.Image.Interface+import Graphics.Image.Processing+import Graphics.Image.Processing.Complex import Graphics.Image.IO.Base import Graphics.Image.IO.Formats.JuicyPixels import Graphics.Image.IO.Formats.Netpbm@@ -115,3 +119,11 @@ encode OutputPNG _ = encode PNG [] encode OutputTGA _ = encode TGA [] encode OutputTIF _ = encode TIF []+++instance (Array arr cs e, Array arr cs (Complex e),+ RealFloat e, Applicative (Pixel cs),+ Writable (Image arr cs e) format) =>+ Writable (Image arr cs (Complex e)) format where+ encode format opts imgC =+ encode format opts (leftToRight (realPartI imgC) (imagPartI imgC))