summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalazsKomuves <>2008-11-04 21:50:30 (GMT)
committerLuite Stegeman <luite@luite.com>2008-11-04 21:50:30 (GMT)
commit77317a672a60835706d39eaea9bba767c2fe1c66 (patch)
treec8e372e7da2a1fd0e3445eb15caaed5267bd46ae
parenta3806953662901b3dbecb5d216c14e997b82b1ac (diff)
version 0.1.10.1.1
-rw-r--r--Codec/Image/STB.hs31
-rw-r--r--LICENSE38
-rw-r--r--cbits/stb_image.c (renamed from Codec/Image/stbi/stb_image.c)0
-rw-r--r--stb-image.cabal42
4 files changed, 74 insertions, 37 deletions
diff --git a/Codec/Image/STB.hs b/Codec/Image/STB.hs
index b9358a9..da5f72b 100644
--- a/Codec/Image/STB.hs
+++ b/Codec/Image/STB.hs
@@ -1,13 +1,13 @@
--
-- Module : Codec.Image.STB
--- Version : 0.1
+-- Version : 0.1.1
-- License : Public Domain
-- Author : Balazs Komuves
--- Maintainer : bkomuves@gmail.com
+-- Maintainer : bkomuves (plus) hackage (at) gmail (dot) com
-- Stability : experimental
-- Portability : portable(?), requires FFI and CPP
--- Tested with : GHC 6.8.2
+-- Tested with : GHC 6.10.1
--
-- |A wrapper around @stb_image@, Sean Barrett's public domain JPEG\/PNG decoder.
@@ -16,8 +16,8 @@
-- The current list of (partially) supported formats is JPEG, PNG, TGA, BMP, PSD.
-- Please note that the library is not (fully) thread-safe!
-{-# LANGUAGE ForeignFunctionInterface #-}
-{-# CFILES Codec/Image/stbi/stb_image.c #-} -- for Hugs (?)
+{-# LANGUAGE ForeignFunctionInterface, CPP #-}
+{-# CFILES cbits/stb_image.c #-} -- for Hugs (?)
module Codec.Image.STB
( Image
, withImage
@@ -104,15 +104,15 @@ foreign import ccall safe "stb_image.h stbi_failure_reason"
-- |Decodes an image from a compressed format stored in a strict 'ByteString'.
-- Supported formats (see @stb_image.c@ for details!):
--
--- * JPEG baseline (no JPEG progressive, no oddball channel decimations)
+-- * JPEG baseline (no JPEG progressive, no oddball channel decimations)
--
--- * PNG 8-bit only (8 bit per component, that is)
+-- * PNG 8-bit only (8 bit per component, that is)
--
--- * BMP non-1bpp, non-RLE
+-- * BMP non-1bpp, non-RLE
--
--- * TGA (not sure what subset, if a subset)
+-- * TGA (not sure what subset, if a subset)
--
--- * PSD (composite view only, no extra channels)
+-- * PSD (composite view only, no extra channels)
--
-- If the operation fails, returns an error message.
decodeImage :: ByteString -> IO (Either String Image)
@@ -137,10 +137,21 @@ decodeImage' forcecomp bs = let (fptr,ofs,len) = toForeignPtr bs in withForeignP
let imgptr = fromForeignPtr fr 0 (xres*yres*comp)
return $ Right $ Image imgptr (xres,yres) comp
+#ifdef STBIMAGE_NEW_EXCEPTIONS
+
+-- base >=4
+ioHandler :: IOException -> IO (Either String a)
+ioHandler ioerror = return $ Left $ ioeGetErrorString ioerror
+
+#else
+
+-- base <=3
ioHandler :: Exception -> IO (Either String a)
ioHandler (IOException ioerror) = return $ Left $ ioeGetErrorString ioerror
ioHandler _ = return $ Left "Unknown error"
+#endif
+
-- |Loads an image from a file. Catches IO exceptions and converts them to an error message.
loadImage :: FilePath -> IO (Either String Image)
loadImage path = handle ioHandler $ do
diff --git a/LICENSE b/LICENSE
index 5cf9667..cd9ef30 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,12 +1,32 @@
http://creativecommons.org/licenses/publicdomain/
-------------------------------------------------
-Copyright-Only Dedication (based on United States law) or Public Domain Certification
-
-The person or persons who have associated work with this document (the "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of his knowledge, the work of authorship identified is in the public domain of the country from which the work is published, or (b) hereby dedicates whatever copyright the dedicators holds in the work of authorship identified below (the "Work") to the public domain. A certifier, moreover, dedicates any copyright interest he may have in the associated work, and for these purposes, is described as a "dedicator" below.
-
-A certifier has taken reasonable steps to verify the copyright status of this work. Certifier recognizes that his good faith efforts may not shield him from liability if in fact the work certified is not in the public domain.
-
-Dedicator makes this dedication for the benefit of the public at large and to the detriment of the Dedicator's heirs and successors. Dedicator intends this dedication to be an overt act of relinquishment in perpetuity of all present and future rights under copyright law, whether vested or contingent, in the Work. Dedicator understands that such relinquishment of all rights includes the relinquishment of all rights to enforce (by lawsuit or otherwise) those copyrights in the Work.
-
-Dedicator recognizes that, once placed in the public domain, the Work may be freely reproduced, distributed, transmitted, used, modified, built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, and in any way, including by methods that have not yet been invented or conceived. \ No newline at end of file
+Copyright-Only Dedication (based on United States law) or
+Public Domain Certification
+
+The person or persons who have associated work with this document (the
+"Dedicator" or "Certifier") hereby either (a) certifies that, to the best of
+his knowledge, the work of authorship identified is in the public domain
+of the country from which the work is published, or (b) hereby dedicates
+whatever copyright the dedicators holds in the work of authorship identified
+below (the "Work") to the public domain. A certifier, moreover, dedicates any
+copyright interest he may have in the associated work, and for these purposes,
+is described as a "dedicator" below.
+
+A certifier has taken reasonable steps to verify the copyright status of this
+work. Certifier recognizes that his good faith efforts may not shield him
+from liability if in fact the work certified is not in the public domain.
+
+Dedicator makes this dedication for the benefit of the public at large and
+to the detriment of the Dedicator's heirs and successors. Dedicator intends
+this dedication to be an overt act of relinquishment in perpetuity of all
+present and future rights under copyright law, whether vested or contingent,
+in the Work. Dedicator understands that such relinquishment of all rights
+includes the relinquishment of all rights to enforce (by lawsuit or otherwise)
+those copyrights in the Work.
+
+Dedicator recognizes that, once placed in the public domain, the Work may
+be freely reproduced, distributed, transmitted, used, modified, built upon,
+or otherwise exploited by anyone for any purpose, commercial or non-commercial,
+and in any way, including by methods that have not yet been invented or
+conceived.
diff --git a/Codec/Image/stbi/stb_image.c b/cbits/stb_image.c
index 0d2c666..0d2c666 100644
--- a/Codec/Image/stbi/stb_image.c
+++ b/cbits/stb_image.c
diff --git a/stb-image.cabal b/stb-image.cabal
index 4448b88..575c8f2 100644
--- a/stb-image.cabal
+++ b/stb-image.cabal
@@ -1,31 +1,37 @@
-Name: stb-image
-Version: 0.1
+Name: stb-image
+Version: 0.1.1
Synopsis: A wrapper around Sean Barrett's JPEG/PNG decoder
Description: Partial implementation of JPEG, PNG, TGA, BMP, PSD decoders,
- with a really simple API.
-License: PublicDomain
-License-file: LICENSE
-Author: Balazs Komuves
-Maintainer: bkomuves@gmail.com
-Stability: Experimental
+ with a really simple API.
+License: PublicDomain
+License-file: LICENSE
+Author: Balazs Komuves
+Maintainer: bkomuves (plus) hackage (at) gmail (dot) com
+Stability: Experimental
Category: Codec
-Tested-With: GHC == 6.8.2
+Tested-With: GHC == 6.10.1
Cabal-Version: >= 1.2
Build-Type: Simple
Extra-Source-Files: example/viewer.hs
-Flag splitBase
- Description: Choose the new smaller, split-up base package.
-
-Library
- if flag(splitBase)
- Build-Depends: base >= 3, bytestring
- else
+Flag splitBase
+ Description: Choose the new smaller, split-up base package.
+
+Library
+ if flag(splitBase)
+ Build-Depends: base >= 3, bytestring
+ else
Build-Depends: base < 3
+
+ -- should check the base version instead of the
+ -- compiler version, but i don't know how to do that...
+ if impl(ghc >= 6.10.1)
+ cpp-options: -DSTBIMAGE_NEW_EXCEPTIONS
+
Exposed-Modules: Codec.Image.STB
Hs-Source-Dirs: .
Extensions: ForeignFunctionInterface, CPP
ghc-options: -Wall
- C-Sources: Codec/Image/stbi/stb_image.c
- Include-Dirs: Codec/Image/stbi
+ C-Sources: cbits/stb_image.c
+ Include-Dirs: cbits
cc-options: -O3 -DSTBI_NO_HDR -DSTBI_NO_STDIO -DSTBI_FAILURE_USERMSG