massiv-io 0.1.7.0 → 0.1.8.0
raw patch · 3 files changed
+19/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- massiv-io.cabal +1/−1
- src/Data/Massiv/Array/IO/Image/JuicyPixels.hs +13/−3
CHANGELOG.md view
@@ -1,3 +1,8 @@+# 0.1.8++* Fix reading images that have more than 8bit per channel:+ [#85](https://github.com/lehins/massiv/issues/85)+ # 0.1.7 * Fix compatibility with `JuicyPixels >= 3.3.0`
massiv-io.cabal view
@@ -1,5 +1,5 @@ name: massiv-io-version: 0.1.7.0+version: 0.1.8.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/Data/Massiv/Array/IO/Image/JuicyPixels.hs view
@@ -79,7 +79,7 @@ import qualified Codec.Picture.Jpg as JP import qualified Codec.Picture.Types as TypesJP import Control.Exception-import Control.Monad (guard, msum)+import Control.Monad (guard, msum, unless) import Data.Bifunctor import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL (ByteString)@@ -1004,10 +1004,20 @@ -- General decoding and helper functions -fromJPImageUnsafe :: forall jpx cs e . (Storable (Pixel cs e), JP.Pixel jpx) =>+fromJPImageUnsafe :: forall jpx cs e . (Storable (Pixel cs e), Storable e, JP.Pixel jpx) => JP.Image jpx -> Maybe (Image S cs e) fromJPImageUnsafe (JP.Image n m !v) = do- guard (n * m * sizeOf (undefined :: Pixel cs e) == V.length v)+ let numberOfComponentsFromSize = sizeOf (undefined :: Pixel cs e) `div` sizeOf (undefined :: e)+ numComponentsPerPixel = JP.componentCount (undefined :: jpx)+ unless (numComponentsPerPixel == numberOfComponentsFromSize) $+ error $+ concat+ [ "Mismatched sizes beteen JuicyPixels: "+ , show numComponentsPerPixel+ , " and massiv: "+ , show numberOfComponentsFromSize+ ]+ guard (n * m * numComponentsPerPixel == V.length v) fromVectorM Par (Sz (m :. n)) $ V.unsafeCast v {-# INLINE fromJPImageUnsafe #-}