packages feed

HDRUtils 1.0.0 → 1.0.1

raw patch · 3 files changed

+31/−15 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Graphics.Image.PixelMap: ixHelper :: Map String (StorableArray (Int, Int) CFloat) -> String -> String -> String -> (CFloat -> CFloat -> CFloat -> Colour CFloat) -> (Int, Int) -> IO (AlphaColour CFloat)
- Graphics.Image.PixelMap: type Channel = StorableArray (Int, Int) Float
+ Graphics.Image.PixelMap: type Channel = StorableArray (Int, Int) CFloat

Files

Graphics/Image/PFS.hs view
@@ -12,6 +12,7 @@ import System.Posix.IO import Control.Applicative +-- | Datatype representing a floating point image frame data FPFrame = FPFrame {     tags :: [(String,String)]   , channelX :: A.StorableArray (Int,Int) CFloat@@ -22,6 +23,7 @@   , height :: Int } +-- | To the portable PixelMap format instance P.ImageData FPFrame where     toPixelMap (FPFrame t x y z cs w h) = P.PixelMap          { P.width=w@@ -31,6 +33,7 @@         , P.tags=t }     fromPixelMap (P.PixelMap t p w h P.Ciea) = FPFrame t (p M.! "X") (p M.! "Y") (p M.! "Z") M.empty w h         +-- | Read a frame from a handle hReadFrame :: Handle -> IO FPFrame hReadFrame fileH = do      fileFd <- fromIntegral <$> handleToFd fileH@@ -68,7 +71,7 @@      return $ FPFrame tagsl xc yc zc M.empty (w) (h) -+-- ! Read a frame from a PFS file readFrameFromFile :: FilePath -> IO FPFrame readFrameFromFile path = do     fileh <- openFile path ReadMode@@ -76,12 +79,14 @@     hClose fileh     return frame +-- | Write a frame to a PFS file writeFrameToFile :: FilePath -> FPFrame -> IO () writeFrameToFile path frame = do         fileh <- openFile path WriteMode     hWriteFrame fileh frame     hClose fileh +-- | Write a frame to a Handle hWriteFrame :: Handle -> FPFrame -> IO () hWriteFrame fileH frame = do     domio <- pfs_newDOMIO@@ -114,9 +119,11 @@     pfs_DOMIOWriteFrame domio frameh fileh     pfs_deleteDOMIO domio +-- | get a frame from stdin getFrame :: IO FPFrame getFrame = hReadFrame stdin +-- | put a frame to stdout putFrame :: FPFrame -> IO () putFrame = hWriteFrame stdout     
Graphics/Image/PixelMap.hs view
@@ -10,27 +10,30 @@ import qualified Data.Map as M import Foreign.C -type Channel = A.StorableArray (Int,Int) Float+-- | type of channels+type Channel = A.StorableArray (Int,Int) CFloat +-- | A pixel map, stored as separate 2D mutable, C-compatible arrays for each channel in w,h order data PixelMap = PixelMap {-     tags :: [(String,String)]-  ,  pixels :: M.Map String (A.StorableArray (Int,Int) CFloat)-  ,  width :: Int-  ,  height :: Int-  ,  colorspace :: ColourSpace +     tags :: [(String,String)]                                  -- ^ tags for TIFF files+  ,  pixels :: M.Map String (A.StorableArray (Int,Int) CFloat)  -- ^ the actual pixels.  if the image is an CIE one then channels will be \"X\", \"Y\", \"Z\" (and possibly more).  If it's RGB, then it's \"R\" \"G\" \"B\" (and possibly more)+  ,  width :: Int                                               -- ^ the width of the image+  ,  height :: Int                                              -- ^ the height of the image+  ,  colorspace :: ColourSpace                                  -- ^ the color space of the image (see "Data.Colour" for more details) } +-- | Converting to and from this portable PixelMap format class ImageData a where-    toPixelMap :: a -> PixelMap-    fromPixelMap :: PixelMap -> a+    toPixelMap :: a -> PixelMap         -- ^ Go to a pixel map from an arbitrary type.+    fromPixelMap :: PixelMap -> a       -- ^ Go from a pixel map to an arbitrary type. +-- | Colourspace monikers representing different spaces in Data.Colour data ColourSpace = -    Ciea -  | Rgba (RGB.RGBSpace CFloat) -  | Srgba -  | SrgbaLinear+    Ciea                            -- ^ CIE XYZa format.  Don't worry if you don't have an alpha channel, it will be filled in if you don't.+  | Rgba (RGB.RGBSpace CFloat)      -- ^ RGBa with a defined colourspace+  | Srgba                           -- ^ SRGBa+  | SrgbaLinear                     -- ^ Linear SRGBa colourspace -ixHelper :: M.Map String (A.StorableArray (Int,Int) CFloat) ->  String ->  String  -> String -> (CFloat -> CFloat -> CFloat -> Colour CFloat) -> (Int,Int) -> IO (AlphaColour CFloat) ixHelper pxs chan0 chan1 chan2 cofun ix = do     a <- (pxs M.! chan0) `A.readArray` ix      b <- (pxs M.! chan1) `A.readArray` ix    @@ -38,24 +41,30 @@     alpha <- maybe (return 1) (`A.readArray` ix) (M.lookup "A" pxs)     return $ cofun a b c `withOpacity` alpha       +-- | Read an arbitrary pixel (!!) :: PixelMap -> (Int, Int) -> IO (AlphaColour CFloat) (PixelMap _ pxs _ _ Ciea) !! ix = ixHelper pxs "X" "Y" "Z" CIE.cieXYZ ix  (PixelMap _ pxs _ _ (Rgba space)) !! ix = ixHelper pxs "R" "G" "B" (RGB.rgbUsingSpace space) ix (PixelMap _ pxs _ _ Srgba) !! ix = ixHelper pxs "R" "G" "B" SRGB.sRGB ix (PixelMap _ pxs _ _ SrgbaLinear) !! ix = ixHelper pxs "R" "G" "B" SRGBLinear.rgb ix +-- | Read one channel from an arbitrary pixel (!/) :: PixelMap -> (Int,Int,String) -> IO CFloat (PixelMap _ pxs _ _ _) !/ (r,c,ch) = maybe (return 1) (`A.readArray` (r,c)) (M.lookup ch pxs)     +-- | Write one channel of an arbitrary pixel (!/=) :: (CFloat -> IO ()) -> CFloat -> IO () a !/= b = a b +-- | Usage: refChan image (0,0) \"R\" !\/= 1.0 refChan :: PixelMap -> (Int,Int) -> String -> CFloat -> IO () refChan mp ix ch = A.writeArray (pixels mp M.! ch) ix +-- | Write a colour to an arbitrary pixel (!=) :: (AlphaColour CFloat -> IO ()) -> AlphaColour CFloat -> IO () a != b = a b +-- | Usage: refPixel image (0,0) != opaque black refPixel :: PixelMap -> (Int,Int) -> AlphaColour CFloat -> IO () refPixel (PixelMap _ pxs _ _ Ciea) ix c = do     let (x,y,z) = CIE.toCIEXYZ $ (1/a) `darken` (c `Data.Colour.over` black)
HDRUtils.cabal view
@@ -1,5 +1,5 @@ name: HDRUtils -version: 1.0.0+version: 1.0.1 cabal-version: >=1.2 build-type: Simple license: BSD3