gd 3000.5.0 → 3000.6
raw patch · 5 files changed
+28/−8 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Graphics.GD: toRGBA :: Color -> (Int, Int, Int, Int)
+ Graphics.GD.ByteString: toRGBA :: Color -> (Int, Int, Int, Int)
+ Graphics.GD.ByteString.Lazy: toRGBA :: Color -> (Int, Int, Int, Int)
Files
- Graphics/GD.hsc +14/−4
- Graphics/GD/ByteString.hs +1/−1
- Graphics/GD/ByteString/Lazy.hs +1/−1
- Graphics/GD/Internal.hsc +11/−1
- gd.cabal +1/−1
Graphics/GD.hsc view
@@ -1,3 +1,4 @@+{-# LANGUAGE EmptyDataDecls #-} module Graphics.GD ( -- * Types Image, Size, Point, Color,@@ -37,20 +38,20 @@ drawString, measureString, drawStringCircle, -- * Colors- rgb, rgba+ rgb, rgba, toRGBA ) where import Control.Exception (bracket) import Control.Monad (liftM, unless)+import Data.Bits import qualified Data.ByteString.Internal as B import Foreign (Ptr,FunPtr,ForeignPtr) import Foreign (peekByteOff) import qualified Foreign as F-import Foreign ((.|.)) import Foreign.C (CInt,CString,CDouble) import qualified Foreign.C as C -data CFILE = CFILE+data CFILE foreign import ccall "stdio.h fopen" c_fopen :: CString -> CString -> IO (Ptr CFILE)@@ -71,7 +72,7 @@ #include <gd.h> #include "gd-extras.h" -data GDImage = GDImage+data GDImage -- JPEG format @@ -191,6 +192,15 @@ foreign import ccall "gd.h &gdFree" gdFree :: FunPtr (Ptr a -> IO ())+ +toRGBA :: Color -> (Int, Int, Int, Int) +toRGBA c = (fromIntegral r, fromIntegral g, fromIntegral b, fromIntegral a)+ where+ b = c `mod` byte+ g = shiftR c 8 `mod` byte+ r = shiftR c 16 `mod` byte+ a = shiftR c 24 `mod` byte+ byte = 2 ^ (8::Int) -- We use a second level of indirection to allow storing a null pointer -- when the image has already been freed. This allows 'withImage' to
Graphics/GD/ByteString.hs view
@@ -40,7 +40,7 @@ measureString, drawStringCircle, -- * Colors- GD.rgb, GD.rgba+ GD.rgb, GD.rgba, GD.toRGBA ) where import Graphics.GD.Internal (Point,Color,Image,GDImage,CFILE,Size)
Graphics/GD/ByteString/Lazy.hs view
@@ -40,7 +40,7 @@ measureString, drawStringCircle, -- * Colors- GD.rgb, GD.rgba+ GD.rgb, GD.rgba, GD.toRGBA ) where import Graphics.GD.Internal (Point,Color,Image,GDImage,CFILE,Size)
Graphics/GD/Internal.hsc view
@@ -2,9 +2,10 @@ import Control.Exception (bracket) import Control.Monad (liftM, unless)+import Data.Bits import Foreign (Ptr,FunPtr,ForeignPtr)+import Foreign (peek,peekByteOff) import qualified Foreign as F-import Foreign (peek,peekByteOff,(.|.)) import Foreign.C (CDouble,CInt,CString) import qualified Foreign.C as C @@ -371,6 +372,15 @@ (int r `F.shiftL` 16) .|. (int g `F.shiftL` 8) .|. int b+ +toRGBA :: Color -> (Int, Int, Int, Int) +toRGBA c = (fromIntegral r, fromIntegral g, fromIntegral b, fromIntegral a)+ where+ b = c `mod` byte+ g = shiftR c 8 `mod` byte+ r = shiftR c 16 `mod` byte+ a = shiftR c 24 `mod` byte+ byte = 2 ^ (8::Int) -- -- * Text
gd.cabal view
@@ -1,7 +1,7 @@ Name: gd Category: Graphics License-File: LICENSE-Version: 3000.5.0+Version: 3000.6 Cabal-version: >= 1.2 Build-type: Simple Copyright: Bjorn Bringert