JuicyPixels 3.1.3.1 → 3.1.3.2
raw patch · 3 files changed
+27/−5 lines, 3 filesdep ~binary
Dependency ranges changed: binary
Files
- JuicyPixels.cabal +3/−3
- changelog +4/−0
- src/Codec/Picture/InternalHelper.hs +20/−2
JuicyPixels.cabal view
@@ -1,5 +1,5 @@ Name: JuicyPixels -Version: 3.1.3.1 +Version: 3.1.3.2 Synopsis: Picture loading/serialization (in png, jpeg, bitmap, gif, tiff and radiance) Description: <<data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADABAMAAACg8nE0AAAAElBMVEUAAABJqDSTWEL/qyb///8AAABH/1GTAAAAAXRSTlMAQObYZgAAAN5JREFUeF7s1sEJgFAQxFBbsAV72v5bEVYWPwT/XDxmCsi7zvHXavYREBDI3XP2GgICqBBYuwIC+/rVayPUAyAg0HvIXBcQoDFDGnUBgWQQ2Bx3AYFaRoBpAQHWb3bt2ARgGAiCYFFuwf3X5HA/McgGJWI2FdykCv4aBYzmKwDwvl6NVmUAAK2vlwEALK7fo88GANB6HQsAAAAAAAAA7P94AQCzswEAAAAAAAAAAAAAAAAAAICzh4UAO4zWAYBfRutHA4Bn5C69JhowAMGoBaMWDG0wCkbBKBgFo2AUAACPmegUST/IJAAAAABJRU5ErkJggg==>> @@ -26,7 +26,7 @@ Source-Repository this Type: git Location: git://github.com/Twinside/Juicy.Pixels.git - Tag: v3.1.3.1 + Tag: v3.1.3.2 Flag Mmap Description: Enable the file loading via mmap (memory map) @@ -50,7 +50,7 @@ Build-depends: base >= 4 && < 5, bytestring >= 0.9 && < 0.11, mtl >= 1.1 && < 2.2, - binary >= 0.6.4.0 && < 0.8, + binary >= 0.5 && < 0.8, zlib >= 0.5.3.1 && < 0.6, transformers >= 0.2.2 && < 0.4, vector >= 0.9 && < 0.11,
changelog view
@@ -1,5 +1,9 @@ -*-change-log-*- +v3.1.3.2 January 2014 + * Hacking around Binary to accept old version of it, down to version 0.5 + allowing Juicy.Pixels to be compiled with GHC 6.3 + v3.1.3.1 January 2014 * Fixing color counting function in color quantisation. * Adding missing documentation for foreign pointer import.
src/Codec/Picture/InternalHelper.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Codec.Picture.InternalHelper ( runGet , runGetStrict , decode @@ -7,15 +8,32 @@ import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as L import Data.Binary( Binary( get ) ) -import Data.Binary.Get( Get, runGetOrFail, getRemainingLazyByteString ) +import Data.Binary.Get( Get + , getRemainingLazyByteString + ) +import qualified Data.Binary.Get as G +#if MIN_VERSION_binary(0,6,4) +#else +import Control.Applicative( (<$>) ) +import qualified Control.Exception as E +-- I feel so dirty. :( +import System.IO.Unsafe( unsafePerformIO ) +#endif + decode :: (Binary a) => B.ByteString -> Either String a decode = runGetStrict get runGet :: Get a -> L.ByteString -> Either String a -runGet act = unpack . runGetOrFail act +#if MIN_VERSION_binary(0,6,4) +runGet act = unpack . G.runGetOrFail act where unpack (Left (_, _, str)) = Left str unpack (Right (_, _, element)) = Right element +#else +runGet act str = unsafePerformIO $ E.catch + (Right <$> E.evaluate (G.runGet act str)) + (\msg -> return . Left $ show (msg :: E.SomeException)) +#endif runGetStrict :: Get a -> B.ByteString -> Either String a runGetStrict act buffer = runGet act $ L.fromChunks [buffer]