packages feed

accelerate-io-JuicyPixels (empty) → 0.1.0.0

raw patch · 7 files changed

+324/−0 lines, 7 filesdep +JuicyPixelsdep +acceleratedep +accelerate-io-vectorsetup-changed

Dependencies added: JuicyPixels, accelerate, accelerate-io-vector, base, vector

Files

+ CHANGELOG.md view
@@ -0,0 +1,12 @@+# Change Log++Notable changes to the project will be documented in this file.++The format is based on [Keep a Changelog](http://keepachangelog.com/) and the+project adheres to the [Haskell Package Versioning+Policy (PVP)](https://pvp.haskell.org)++## [0.1.0.0] - 2020-08-26+### New+  * Initial release+
+ LICENSE view
@@ -0,0 +1,23 @@+Copyright (c) [2007..2012] The Accelerate Team.  All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:+    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.+    * Redistributions in binary form must reproduce the above copyright+      notice, this list of conditions and the following disclaimer in the+      documentation and/or other materials provided with the distribution.+    * Neither the names of the contributors nor of their affiliations may+      be used to endorse or promote products derived from this software+      without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,25 @@+<div align="center">+<img width="450" src="https://github.com/AccelerateHS/accelerate/raw/master/images/accelerate-logo-text-v.png?raw=true" alt="henlo, my name is Theia"/>++# Array conversion components for the Accelerate language++[![GitHub CI](https://github.com/tmcdonell/accelerate-io/workflows/CI/badge.svg)](https://github.com/tmcdonell/accelerate-io/actions)+[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/AccelerateHS/Lobby)+<br>+[![Stackage LTS](https://stackage.org/package/accelerate-io/badge/lts)](https://stackage.org/lts/package/accelerate-io)+[![Stackage Nightly](https://stackage.org/package/accelerate-io/badge/nightly)](https://stackage.org/nightly/package/accelerate-io)+[![Hackage](https://img.shields.io/hackage/v/accelerate-io.svg)](https://hackage.haskell.org/package/accelerate-io)++</div>++Efficient conversion routines between Accelerate arrays and a range of data+formats.++For details on Accelerate, refer to the [main repository][GitHub].++Contributions and bug reports are welcome!<br>+Please feel free to contact me through [GitHub][GitHub] or [gitter.im][gitter.im].++  [GitHub]:     https://github.com/AccelerateHS/accelerate+  [gitter.im]:  https://gitter.im/AccelerateHS/Lobby+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ accelerate-io-JuicyPixels.cabal view
@@ -0,0 +1,53 @@+name:                   accelerate-io-JuicyPixels+version:                0.1.0.0+cabal-version:          >= 1.10+build-type:             Simple++synopsis:               Convert between Accelerate arrays and JuicyPixels images+Description:+  This package provides efficient conversion routines between Accelerate arrays+  and image types supported by JuicyPixels.+  .+  Refer to the main /Accelerate/ package for more information:+  <http://hackage.haskell.org/package/accelerate>++license:                BSD3+license-file:           LICENSE+author:                 The Accelerate Team+maintainer:             Trevor L. McDonell <trevor.mcdonell@gmail.com>+homepage:               https://github.com/AccelerateHS/accelerate-io#readme+bug-reports:            https://github.com/AccelerateHS/accelerate-io/issues+category:               Accelerate, Data++extra-source-files:+    README.md+    CHANGELOG.md++library+  build-depends:+          base                      >= 4.8 && < 5+        , accelerate                >= 1.3+        , accelerate-io-vector      >= 0.1+        , vector+        , JuicyPixels               >= 3.2++  exposed-modules:+        Data.Array.Accelerate.IO.Codec.Picture+        Data.Array.Accelerate.IO.Codec.Picture.Types++  ghc-options:+        -O2+        -Wall+        -funbox-strict-fields++  ghc-prof-options:+        -fprof-auto++  hs-source-dirs:   src+  default-language: Haskell2010++source-repository head+  type:     git+  location: https://github.com/AccelerateHS/accelerate-io++-- vim: nospell
+ src/Data/Array/Accelerate/IO/Codec/Picture.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TypeFamilies    #-}+-- |+-- Module      : Data.Array.Accelerate.IO.Codec.Picture+-- Copyright   : [2019..2020] The Accelerate Team+-- License     : BSD3+--+-- Maintainer  : Trevor L. McDonell <trevor.mcdonell@gmail.com>+-- Stability   : experimental+-- Portability : non-portable (GHC extensions)+--++module Data.Array.Accelerate.IO.Codec.Picture (++  imageOfArray,+  arrayOfImage,+  module Data.Array.Accelerate.IO.Codec.Picture.Types,++) where++import Data.Array.Accelerate                                        hiding ( Vector )+import Data.Array.Accelerate.Sugar.Elt+import Data.Array.Accelerate.IO.Codec.Picture.Types+import Data.Array.Accelerate.IO.Data.Vector.Storable++import Data.Vector.Storable                                         ( Vector )+++-- | /O(1)/. Convert an Accelerate 'Array' into an 'Image'.+--+imageOfArray+    :: (Elt pixel, Vector (PixelBaseComponent pixel) ~ Vectors (EltR pixel))+    => Array DIM2 pixel+    -> Image pixel+imageOfArray arr =+  let Z :. imageHeight :. imageWidth = arrayShape arr+      imageData                      = toVectors arr+  in+  Image{..}++-- | /O(1)/. Convert an 'Image' into an Accelerate 'Array'.+--+arrayOfImage+    :: (Elt pixel, Vector (PixelBaseComponent pixel) ~ Vectors (EltR pixel))+    => Image pixel+    -> Array DIM2 pixel+arrayOfImage Image{..} =+  fromVectors (Z :. imageHeight :. imageWidth) imageData+
+ src/Data/Array/Accelerate/IO/Codec/Picture/Types.hs view
@@ -0,0 +1,160 @@+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE PatternSynonyms       #-}+{-# LANGUAGE ScopedTypeVariables   #-}+{-# LANGUAGE TypeApplications      #-}+{-# LANGUAGE TypeFamilies          #-}+{-# LANGUAGE UndecidableInstances  #-}+{-# LANGUAGE ViewPatterns          #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+-- |+-- Module      : Data.Array.Accelerate.IO.Codec.Picture.Types+-- Copyright   : [2019..2020] The Accelerate Team+-- License     : BSD3+--+-- Maintainer  : Trevor L. McDonell <trevor.mcdonell@gmail.com>+-- Stability   : experimental+-- Portability : non-portable (GHC extensions)+--++module Data.Array.Accelerate.IO.Codec.Picture.Types (++  Image(..),+  Pixel(PixelBaseComponent),+  Pixel8, Pixel16, Pixel32, PixelF,++  PixelYA8(..),     pattern PixelYA8_,+  PixelYA16(..),    pattern PixelYA16_,+  PixelRGB8(..),    pattern PixelRGB8_,+  PixelRGB16(..),   pattern PixelRGB16_,+  PixelRGBF(..),    pattern PixelRGBF_,+  PixelRGBA8(..),   pattern PixelRGBA8_,+  PixelRGBA16(..),  pattern PixelRGBA16_,+  PixelCMYK8(..),   pattern PixelCMYK8_,+  PixelCMYK16(..),  pattern PixelCMYK16_,+  PixelYCbCr8(..),  pattern PixelYCbCr8_,+  PixelYCbCrK8(..), pattern PixelYCbCrK8_,++) where++import Data.Array.Accelerate+import Data.Array.Accelerate.Representation.Tag+import Data.Array.Accelerate.Representation.Type+import Data.Array.Accelerate.Sugar.Elt+import Data.Array.Accelerate.Type+import Data.Primitive.Vec++import Codec.Picture.Types+++pattern PixelYA8_ :: Exp Pixel8 -> Exp Pixel8 -> Exp PixelYA8+pattern PixelYA8_ y a = V2 y a++pattern PixelYA16_ :: Exp Pixel16 -> Exp Pixel16 -> Exp PixelYA16+pattern PixelYA16_ y a = V2 y a++pattern PixelRGB8_ :: Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp PixelRGB8+pattern PixelRGB8_ r g b = V3 r g b++pattern PixelRGB16_ :: Exp Pixel16 -> Exp Pixel16 -> Exp Pixel16 -> Exp PixelRGB16+pattern PixelRGB16_ r g b = V3 r g b++pattern PixelRGBF_ :: Exp PixelF -> Exp PixelF -> Exp PixelF -> Exp PixelRGBF+pattern PixelRGBF_ r g b = V3 r g b++pattern PixelRGBA8_ :: Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp PixelRGBA8+pattern PixelRGBA8_ r g b a = V4 r g b a++pattern PixelRGBA16_ :: Exp Pixel16 -> Exp Pixel16 -> Exp Pixel16 -> Exp Pixel16 -> Exp PixelRGBA16+pattern PixelRGBA16_ r g b a = V4 r g b a++pattern PixelCMYK8_ :: Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp PixelCMYK8+pattern PixelCMYK8_ r g b a = V4 r g b a++pattern PixelCMYK16_ :: Exp Pixel16 -> Exp Pixel16 -> Exp Pixel16 -> Exp Pixel16 -> Exp PixelCMYK16+pattern PixelCMYK16_ r g b a = V4 r g b a++pattern PixelYCbCr8_ :: Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp PixelYCbCr8+pattern PixelYCbCr8_ y cb cr = V3 y cb cr++pattern PixelYCbCrK8_ :: Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp Pixel8 -> Exp PixelYCbCrK8+pattern PixelYCbCrK8_ y cb cr k = V4 y cb cr k+++instance Elt PixelYA8 where+  type EltR PixelYA8 = Vec2 Pixel8+  eltR                   = TupRsingle (VectorScalarType (VectorType 2 singleType))+  tagsR                  = [ TagRsingle (VectorScalarType (VectorType 2 singleType)) ]+  toElt (Vec2 y a)       = PixelYA8 y a+  fromElt (PixelYA8 y a) = Vec2 y a++instance Elt PixelYA16 where+  type EltR PixelYA16 = Vec2 Pixel16+  eltR                    = TupRsingle (VectorScalarType (VectorType 2 singleType))+  tagsR                   = [ TagRsingle (VectorScalarType (VectorType 2 singleType)) ]+  toElt (Vec2 y a)        = PixelYA16 y a+  fromElt (PixelYA16 y a) = Vec2 y a++instance Elt PixelRGB8 where+  type EltR PixelRGB8 = Vec3 Pixel8+  eltR                      = TupRsingle (VectorScalarType (VectorType 3 singleType))+  tagsR                     = [ TagRsingle (VectorScalarType (VectorType 3 singleType)) ]+  toElt (Vec3 r g b)        = PixelRGB8 r g b+  fromElt (PixelRGB8 r g b) = Vec3 r g b++instance Elt PixelRGB16 where+  type EltR PixelRGB16 = Vec3 Pixel16+  eltR                       = TupRsingle (VectorScalarType (VectorType 3 singleType))+  tagsR                      = [ TagRsingle (VectorScalarType (VectorType 3 singleType)) ]+  toElt (Vec3 r g b)         = PixelRGB16 r g b+  fromElt (PixelRGB16 r g b) = Vec3 r g b++instance Elt PixelRGBF where+  type EltR PixelRGBF = Vec3 PixelF+  eltR                      = TupRsingle (VectorScalarType (VectorType 3 singleType))+  tagsR                     = [ TagRsingle (VectorScalarType (VectorType 3 singleType)) ]+  toElt (Vec3 r g b)        = PixelRGBF r g b+  fromElt (PixelRGBF r g b) = Vec3 r g b++instance Elt PixelRGBA8 where+  type EltR PixelRGBA8 = Vec4 Pixel8+  eltR                         = TupRsingle (VectorScalarType (VectorType 4 singleType))+  tagsR                        = [ TagRsingle (VectorScalarType (VectorType 4 singleType)) ]+  toElt (Vec4 r g b a)         = PixelRGBA8 r g b a+  fromElt (PixelRGBA8 r g b a) = Vec4 r g b a++instance Elt PixelRGBA16 where+  type EltR PixelRGBA16 = Vec4 Pixel16+  eltR                          = TupRsingle (VectorScalarType (VectorType 4 singleType))+  tagsR                         = [ TagRsingle (VectorScalarType (VectorType 4 singleType)) ]+  toElt (Vec4 r g b a)          = PixelRGBA16 r g b a+  fromElt (PixelRGBA16 r g b a) = Vec4 r g b a++instance Elt PixelCMYK8 where+  type EltR PixelCMYK8 = Vec4 Pixel8+  eltR                         = TupRsingle (VectorScalarType (VectorType 4 singleType))+  tagsR                        = [ TagRsingle (VectorScalarType (VectorType 4 singleType)) ]+  toElt (Vec4 c m y k)         = PixelCMYK8 c m y k+  fromElt (PixelCMYK8 c m y k) = Vec4 c m y k++instance Elt PixelCMYK16 where+  type EltR PixelCMYK16 = Vec4 Pixel16+  eltR                          = TupRsingle (VectorScalarType (VectorType 4 singleType))+  tagsR                         = [ TagRsingle (VectorScalarType (VectorType 4 singleType)) ]+  toElt (Vec4 c m y k)          = PixelCMYK16 c m y k+  fromElt (PixelCMYK16 c m y k) = Vec4 c m y k++instance Elt PixelYCbCr8 where+  type EltR PixelYCbCr8 = Vec3 Pixel8+  eltR                          = TupRsingle (VectorScalarType (VectorType 3 singleType))+  tagsR                         = [ TagRsingle (VectorScalarType (VectorType 3 singleType)) ]+  toElt (Vec3 y cb cr)          = PixelYCbCr8 y cb cr+  fromElt (PixelYCbCr8 y cb cr) = Vec3 y cb cr++instance Elt PixelYCbCrK8 where+  type EltR PixelYCbCrK8 = Vec4 Pixel8+  eltR                             = TupRsingle (VectorScalarType (VectorType 4 singleType))+  tagsR                            = [ TagRsingle (VectorScalarType (VectorType 4 singleType)) ]+  toElt (Vec4 y cb cr k)           = PixelYCbCrK8 y cb cr k+  fromElt (PixelYCbCrK8 y cb cr k) = Vec4 y cb cr k+