packages feed

JuicyPixels-extra 0.2.2 → 0.3.0

raw patch · 5 files changed

+42/−15 lines, 5 filesdep ~JuicyPixelsdep ~criterionPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: JuicyPixels, criterion

API changes (from Hackage documentation)

- Codec.Picture.Extra: scaleBilinear :: Int -> Int -> Image PixelRGB8 -> Image PixelRGB8
+ Codec.Picture.Extra: scaleBilinear :: (Pixel a, Integral (PixelBaseComponent a)) => Int -> Int -> Image a -> Image a

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+## Juicy Pixels Extra 0.3.0++* Made the function `scaleBilinear` polymorphic in pixel type.+ ## Juicy Pixels Extra 0.2.2  * Fixed a bug in the `crop` function related to incorrect calculation of new
Codec/Picture/Extra.hs view
@@ -1,6 +1,6 @@ -- | -- Module      :  Codec.Picture.Extra--- Copyright   :  © 2016–2017 Mark Karpov+-- Copyright   :  © 2016–2018 Mark Karpov -- License     :  BSD 3 clause -- -- Maintainer  :  Mark Karpov <markkarpov92@gmail.com>@@ -9,7 +9,9 @@ -- -- Utilities for image transformation with JuicyPixels. -{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE CPP              #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE RecordWildCards  #-}  module Codec.Picture.Extra   ( -- * Scaling@@ -29,18 +31,18 @@  import Codec.Picture import Control.Monad.ST-import qualified Codec.Picture.Types as M import Data.List (foldl1')+import qualified Codec.Picture.Types as M  -- | Scale an image using bi-linear interpolation. This is specialized to -- 'PixelRGB8' only for speed (polymorphic version is easily written, but -- it's more than twice as slow). -scaleBilinear-  :: Int               -- ^ Desired width+scaleBilinear :: (Pixel a, Integral (PixelBaseComponent a))+  => Int               -- ^ Desired width   -> Int               -- ^ Desired height-  -> Image PixelRGB8   -- ^ Original image-  -> Image PixelRGB8   -- ^ Scaled image+  -> Image a           -- ^ Original image+  -> Image a           -- ^ Scaled image scaleBilinear width height img@Image {..} = runST $ do   mimg <- M.newMutableImage width height   let sx, sy :: Float@@ -59,7 +61,7 @@                 δy = yf - fromIntegral y                 pixelAt' i j =                   if i >= imageWidth || j >= imageHeight-                    then PixelRGB8 0 0 0+                    then toBlack (pixelAt img 0 0)                     else pixelAt img i j             writePixel mimg x' y' $               mulp (pixelAt' x y) ((1 - δx) * (1 - δy)) `addp`@@ -69,11 +71,32 @@             go (x' + 1) y'   go 0 0 -mulp :: PixelRGB8 -> Float -> PixelRGB8+#define scaleBilinear_spec(pixel) \+{-# SPECIALIZE scaleBilinear :: Int -> Int -> Image pixel -> Image pixel #-}++scaleBilinear_spec(M.PixelRGBA16)+scaleBilinear_spec(M.PixelRGBA8)+scaleBilinear_spec(M.PixelCMYK16)+scaleBilinear_spec(M.PixelCMYK8)+scaleBilinear_spec(M.PixelYCbCr8)+scaleBilinear_spec(M.PixelRGB16)+scaleBilinear_spec(M.PixelYCbCrK8)+scaleBilinear_spec(M.PixelRGB8)+scaleBilinear_spec(M.PixelYA16)+scaleBilinear_spec(M.PixelYA8)+scaleBilinear_spec(M.Pixel32)+scaleBilinear_spec(M.Pixel16)+scaleBilinear_spec(M.Pixel8)++toBlack :: Pixel a => a -> a+toBlack = colorMap (const 0)+{-# INLINE toBlack #-}++mulp :: (Pixel a, Integral (PixelBaseComponent a)) => a -> Float -> a mulp pixel x = colorMap (floor . (* x) . fromIntegral) pixel {-# INLINE mulp #-} -addp :: PixelRGB8 -> PixelRGB8 -> PixelRGB8+addp :: (Pixel a, Integral (PixelBaseComponent a)) => a -> a -> a addp = mixWith (const f)   where     f x y = fromIntegral $
JuicyPixels-extra.cabal view
@@ -1,7 +1,7 @@ name:                 JuicyPixels-extra-version:              0.2.2+version:              0.3.0 cabal-version:        >= 1.18-tested-with:          GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.1+tested-with:          GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.2 license:              BSD3 license-file:         LICENSE.md author:               Mark Karpov <markkarpov92@gmail.com>@@ -57,7 +57,7 @@   build-depends:      base              >= 4.7 && < 5.0                     , JuicyPixels       >= 3.2.6.4 && < 3.3                     , JuicyPixels-extra-                    , criterion         >= 0.6.2.1 && < 1.3+                    , criterion         >= 0.6.2.1 && < 1.4   if flag(dev)     ghc-options:      -O2 -Wall -Werror   else
LICENSE.md view
@@ -1,4 +1,4 @@-Copyright © 2016–2017 Mark Karpov+Copyright © 2016–2018 Mark Karpov  All rights reserved. 
README.md view
@@ -12,6 +12,6 @@  ## License -Copyright © 2016–2017 Mark Karpov+Copyright © 2016–2018 Mark Karpov  Distributed under BSD 3 clause license.