bitmaps 0.2.6.0 → 0.2.6.3
raw patch · 8 files changed
+151/−57 lines, 8 filesdep ~basedep ~bitmapdep ~monad-state
Dependency ranges changed: base, bitmap, monad-state
Files
- CHANGELOG.md +24/−0
- README.md +0/−0
- bitmaps.cabal +96/−27
- src/Data/Bitmap/Foreign.hs +19/−17
- src/Data/Bitmap/Pixel.hs +7/−7
- src/Data/Bitmap/String/Internal.hs +1/−2
- src/Data/Bitmap/StringRGB24A4VR/Internal.hs +2/−2
- src/Data/Bitmap/StringRGB32/Internal.hs +2/−2
+ CHANGELOG.md view
@@ -0,0 +1,24 @@+PLACEHOLDER+-----++0.2.6.3+-----+* Fixed build errors.+ * Hide imports of `get` from `Control.Monad.Record`.+ * Support ``bitmap-0.0.2``s new major API changes that don't conform to the+ cabal's package versioning policy.+ * Replaced imports of `Foreign` with `System.IO.Unsafe` for `unsafePerformIO`.+ `Foreign` no longer provides `unsafePerformIO`.+ * Replaced calls to `lens` with calls to `lensGS`, since fc-labels recently+ changed lens to take a getter and a modifier rather than a getter and a+ setter. Eventually this library will be ported from `fc-labels` to `lens`,+ which was written after this project was first developed.+* Fixed warnings.+ * Removed redundant import of `Control.Bitmap.Searchable` from+ `Data.Bitmap.String.Internal`.++0.2.6.2+-----+* Add homepage and bug-reports to cabal file, linking to the github repository+ and its issue tracker, respectively.+* Added `CHANGELOG.md`.
+ README.md view
bitmaps.cabal view
@@ -1,31 +1,100 @@-name: bitmaps-version: 0.2.6.0-cabal-version: >= 1.10-build-type: Simple-license: BSD3-license-file: LICENSE-copyright: Copyright (C) 2010 Byron James Johnson-author: Byron James Johnson-maintainer: KrabbyKrap@gmail.com-synopsis: Bitmap library-description: Library defining several bitmap types, including ones stored as unboxed arrays, any string type, and functions- .- This library also supports conversion to and from bitmaps as defined in the "bitmap" package.- .- This library has not yet been tested extensively.- .- Note: This library is currently largely designed with RGB pixels with a color depth of 24 bits in mind. Better support for other pixel and color formats is intended to be implemented in the future.-category: Graphics, Codec, Data-tested-with: GHC == 7.0.1+name: bitmaps+-- Don't forget to bump the tag and CHANGELOG placeholder too.+version: 0.2.6.3+cabal-version: >= 1.18+build-type: Simple+license: BSD3+license-file: LICENSE+copyright: Copyright (C) 2010 Byron James Johnson+author: Byron James Johnson+maintainer: ByronJohnsonFP@gmail.com+category: Graphics, Codec, Data+homepage: https://github.com/bairyn/bitmaps+bug-reports: https://github.com/bairyn/bitmaps/issues+tested-with: GHC == 7.8.3+extra-source-files:+-- The extra-doc-files property requires cabal-version >= 1.18.+extra-doc-files:+ README.md+ ,CHANGELOG.md+synopsis: Bitmap library+description:+ Library defining several bitmap types, including ones stored as unboxed+ arrays, any string type, and functions+ .+ This library also supports conversion to and from bitmaps as defined in the+ "bitmap" package.+ .+ This library has not yet been tested extensively.+ .+ Note: This library is currently largely designed with RGB pixels with a+ color depth of 24 bits in mind. Better support for other pixel and color+ formats is intended to be implemented in the future. library- default-language: Haskell2010- hs-source-dirs: src- build-depends: base >= 4 && < 5, array, containers, binary, cereal, monad-state, zlib, bitmap, stb-image, string-class >= 0.1.5.0, tagged, bytestring- exposed-modules: Codec.String.Base16, Codec.String.Base64, Data.Bitmap.Array, Data.Bitmap.Array.Internal, Data.Bitmap.BMP, Data.Bitmap.Class, Data.Bitmap.Croppable, Data.Bitmap.Foreign, Data.Bitmap.Function, Data.Bitmap.Function.Internal, Data.Bitmap.Pixel, Data.Bitmap.Reflectable, Data.Bitmap.Searchable, Data.Bitmap.String, Data.Bitmap.String.Internal, Data.Bitmap.StringRGB24A4VR, Data.Bitmap.StringRGB24A4VR.Internal, Data.Bitmap.StringRGB32, Data.Bitmap.StringRGB32.Internal, Data.Bitmap.Types, Data.Bitmap.Util- ghc-options: -Wall -O2- other-extensions: ScopedTypeVariables, TypeFamilies, GeneralizedNewtypeDeriving, PolymorphicComponents, TupleSections, FlexibleContexts, TemplateHaskell, DeriveDataTypeable, ExistentialQuantification, TypeOperators, FlexibleInstances, OverlappingInstances, UndecidableInstances+ default-language: Haskell2010+ hs-source-dirs: src+ ghc-options: -Wall+ default-extensions:+ --,GADTs+ TemplateHaskell+ ,DeriveDataTypeable+ other-extensions:+ ScopedTypeVariables+ ,TypeFamilies+ ,GeneralizedNewtypeDeriving+ ,PolymorphicComponents+ ,TupleSections+ ,FlexibleContexts+ ,TemplateHaskell+ ,DeriveDataTypeable+ ,ExistentialQuantification+ ,TypeOperators+ ,FlexibleInstances+ ,OverlappingInstances+ ,UndecidableInstances+ -- TODO: add version constraints.+ build-depends:+ base >= 4 && < 5+ ,array+ ,containers+ ,binary+ ,cereal+ ,monad-state >= 0.1.1.3+ ,zlib+ ,bitmap >= 0.0.2+ ,stb-image+ ,string-class >= 0.1.5.0+ ,tagged+ ,bytestring+ exposed-modules:+ Codec.String.Base16+ ,Codec.String.Base64+ ,Data.Bitmap.Array+ ,Data.Bitmap.Array.Internal+ ,Data.Bitmap.BMP+ ,Data.Bitmap.Class+ ,Data.Bitmap.Croppable+ ,Data.Bitmap.Foreign+ ,Data.Bitmap.Function+ ,Data.Bitmap.Function.Internal+ ,Data.Bitmap.Pixel+ ,Data.Bitmap.Reflectable+ ,Data.Bitmap.Searchable+ ,Data.Bitmap.String+ ,Data.Bitmap.String.Internal+ ,Data.Bitmap.StringRGB24A4VR+ ,Data.Bitmap.StringRGB24A4VR.Internal+ ,Data.Bitmap.StringRGB32+ ,Data.Bitmap.StringRGB32.Internal+ ,Data.Bitmap.Types+ ,Data.Bitmap.Util source-repository head- type: darcs- location: http://patch-tag.com/r/bob/abitmap+ type: git+ location: git@github.com:bairyn/bitmaps.git++source-repository this+ type: git+ location: git@github.com:bairyn/bitmaps.git+ tag: v0.2.6.3
src/Data/Bitmap/Foreign.hs view
@@ -1,23 +1,25 @@ {-# LANGUAGE TypeFamilies, ScopedTypeVariables #-} --- | Wrapping interface for bitmaps as defined by the 'bitmap' package-+-- | Wrapping interface for 'IOBitmap's as defined by the "bitmap" package+--+-- TODO: Add support for "bitmap"'s pure bitmap type.+-- Since this package was originally written, 'bitmap' version 0.0.2 was+-- released with new support for using both 'IOBitmap's and pure @Bitmap@s. module Data.Bitmap.Foreign ( FBBitmapBase , BitmapForeign(..) ) where -import Control.Monad.Record-import qualified Data.Bitmap as FB-import qualified Data.Bitmap.IO as FB-import Data.Bitmap.Class-import Data.Bitmap.Pixel-import Data.Bitmap.Types-import Foreign (unsafePerformIO)-import Foreign.Storable-import Text.Printf+import Control.Monad.Record+import qualified Data.Bitmap.IO as FB+import Data.Bitmap.Class+import Data.Bitmap.Pixel+import Data.Bitmap.Types+import Foreign.Storable+import System.IO.Unsafe (unsafePerformIO)+import Text.Printf -type FBBitmapBase = FB.Bitmap+type FBBitmapBase = FB.IOBitmap -- | The foreign bitmap as defined by the "bitmap" package --@@ -31,14 +33,14 @@ type BIndexType BitmapForeign = Int type BPixelType BitmapForeign = PixelRGB - depth (BitmapForeign b) = unsafePerformIO . FB.withBitmap b $ \_ numComponents _ _ -> case numComponents of+ depth (BitmapForeign b) = unsafePerformIO . FB.withIOBitmap b $ \_ numComponents _ _ -> case numComponents of 3 -> return Depth24RGB 4 -> return Depth32RGBA _ -> return $ error $ printf "Bitmap.ForeignBitmap.depth: invalid numConponents value: %d" numComponents - dimensions (BitmapForeign b) = unsafePerformIO . FB.withBitmap b $ \dms _ _ _ -> return dms+ dimensions (BitmapForeign b) = unsafePerformIO . FB.withIOBitmap b $ \dms _ _ _ -> return dms - getPixel (BitmapForeign b) (row, column) = unsafePerformIO . FB.withBitmap b $ \(w, _) numComponents padding ptr -> do+ getPixel (BitmapForeign b) (row, column) = unsafePerformIO . FB.withIOBitmap b $ \(w, _) numComponents padding ptr -> do let bytesPixel = numComponents bytesRow = bytesPixel * w + padding offset = bytesRow * row + bytesPixel * column@@ -48,8 +50,8 @@ return . (red =: thisRed) . (green =: thisGreen) . (blue =: thisBlue) $ leastIntensity constructPixels f dms@(w, _) = unsafePerformIO $ do let bytesPixel = 3- fbBitmap <- FB.newBitmap dms bytesPixel (Just 4)- FB.withBitmap fbBitmap $ \(width, height) _ padding ptr -> do+ fbBitmap <- FB.newIOBitmap dms bytesPixel (Just 4)+ FB.withIOBitmap fbBitmap $ \(width, height) _ padding ptr -> do let bytesRow = bytesPixel * w + padding maxRow = abs . pred $ height maxColumn = abs . pred $ width
src/Data/Bitmap/Pixel.hs view
@@ -46,11 +46,11 @@ import Data.Maybe import qualified Data.String.Class as S import Data.Word-import Foreign (unsafePerformIO) import Foreign.C.Types import Foreign.Ptr import Foreign.Marshal.Utils import Foreign.Storable+import System.IO.Unsafe (unsafePerformIO) class (Integral a, ConvPixelRGB a, ConvPixelRGBA a, ConvPixelBGR a, ConvPixelBGRA a) => Pixel a where red :: a :-> PixelComponent@@ -128,9 +128,9 @@ deriving (Eq, Bounded, Enum, Ord, Real, Integral, Bits, Num, Show, Data, Typeable) byteLens :: (Integral p, Bits p) => Integer -> (p :-> Word8)-byteLens 0 = lens (fromIntegral) (\w p -> (p .&. complement 0xFF) .|. fromIntegral w)+byteLens 0 = lensGS (fromIntegral) (\w p -> (p .&. complement 0xFF) .|. fromIntegral w) byteLens i = let i' = fromIntegral i- in lens (fromIntegral . (`shiftR` i')) (\w p -> (p .&. complement (0xFF `shiftL` i')) .|. fromIntegral w `shiftL` i')+ in lensGS (fromIntegral . (`shiftR` i')) (\w p -> (p .&. complement (0xFF `shiftL` i')) .|. fromIntegral w `shiftL` i') instance Pixel PixelRGB where red = byteLens 16@@ -272,7 +272,7 @@ lsetter i = \component storage -> storage .|. (((fromIntegral (component :: GenPixelComponent)) :: GenPixelStorage) `shiftL` (fromIntegral i)) genRed :: GenPixel :-> GenPixelComponent-genRed = lens getter setter+genRed = lensGS getter setter where getter (GenPixelRGB storage) = lgetter 16 storage getter (GenPixelBGR storage) = lgetter 0 storage getter (GenPixelRGBA storage) = lgetter 24 storage@@ -283,7 +283,7 @@ setter component (GenPixelBGRA storage) = GenPixelBGRA $ lsetter 8 component storage genGreen :: GenPixel :-> GenPixelComponent-genGreen = lens getter setter+genGreen = lensGS getter setter where getter (GenPixelRGB storage) = lgetter 8 storage getter (GenPixelBGR storage) = lgetter 8 storage getter (GenPixelRGBA storage) = lgetter 16 storage@@ -294,7 +294,7 @@ setter component (GenPixelBGRA storage) = GenPixelBGRA $ lsetter 16 component storage genBlue :: GenPixel :-> GenPixelComponent-genBlue = lens getter setter+genBlue = lensGS getter setter where getter (GenPixelRGB storage) = lgetter 0 storage getter (GenPixelBGR storage) = lgetter 16 storage getter (GenPixelRGBA storage) = lgetter 8 storage@@ -305,7 +305,7 @@ setter component (GenPixelBGRA storage) = GenPixelBGRA $ lsetter 24 component storage genAlpha :: GenPixel :-> GenPixelComponent-genAlpha = lens getter setter+genAlpha = lensGS getter setter where getter (GenPixelRGB _) = greatestIntensityComponent getter (GenPixelBGR _) = greatestIntensityComponent getter (GenPixelRGBA storage) = lgetter 0 storage
src/Data/Bitmap/String/Internal.hs view
@@ -30,14 +30,13 @@ import Control.Applicative --import Control.Arrow -- See serializers part of 'BitmapString's 'Bitmap' instance-import Control.Monad.Record+import Control.Monad.Record hiding (get) import Data.Bits import Data.Binary import Data.Bitmap.Class import Data.Bitmap.Croppable import Data.Bitmap.Pixel import Data.Bitmap.Reflectable-import Data.Bitmap.Searchable import Data.Bitmap.Types import Data.Bitmap.Util import qualified Data.ByteString.Lazy as B
src/Data/Bitmap/StringRGB24A4VR/Internal.hs view
@@ -14,14 +14,14 @@ import Control.Applicative import Control.Arrow-import Control.Monad.Record+import Control.Monad.Record hiding (get) import Data.Binary import Data.Bitmap.Class import Data.Bitmap.Pixel import Data.Bitmap.Reflectable import Data.Bitmap.Searchable import Data.Bitmap.Types-import Data.Bitmap.Util hiding (padByte)+import Data.Bitmap.Util hiding (padByte) import Data.Bits import qualified Data.ByteString as B import qualified Data.Serialize as S
src/Data/Bitmap/StringRGB32/Internal.hs view
@@ -10,14 +10,14 @@ import Control.Applicative import Control.Arrow-import Control.Monad.Record+import Control.Monad.Record hiding (get) import Data.Binary import Data.Bitmap.Class import Data.Bitmap.Pixel import Data.Bitmap.Reflectable import Data.Bitmap.Searchable import Data.Bitmap.Types-import Data.Bitmap.Util hiding (padByte)+import Data.Bitmap.Util hiding (padByte) import Data.Bits import qualified Data.ByteString as B import qualified Data.Serialize as S