gloss-juicy 0.1.1 → 0.1.2
raw patch · 3 files changed
+6/−13 lines, 3 files
Files
- Graphics/Gloss/Juicy.hs +1/−1
- gloss-juicy.cabal +3/−1
- gloss-juicy.hs +2/−11
Graphics/Gloss/Juicy.hs view
@@ -47,7 +47,7 @@ -- | O(N) conversion from 'PixelRGBA8' image to gloss 'Picture', where N is the number of pixels. fromImageRGBA8 :: Image PixelRGBA8 -> Picture fromImageRGBA8 img@(Image { imageWidth = w, imageHeight = h, imageData = _ }) =- bitmapOfForeignPtr w h ptr False+ bitmapOfForeignPtr w h ptr True where swapedImage = horizontalSwap img (ptr, _, _) = unsafeToForeignPtr $ imageData swapedImage {-# INLINE fromImageRGBA8 #-}
gloss-juicy.cabal view
@@ -1,7 +1,9 @@ name: gloss-juicy-version: 0.1.1+version: 0.1.2 synopsis: Load any image supported by Juicy.Pixels in your gloss application description: Lets you convert any image supported by Juicy.Pixels in a gloss application by converting to gloss' Bitmap representation.+ .+ Version 0.1.2 just enabled caching (from a frame to the next, and so on) of the images you load, so that they are not recomputed for each frame. Credits go to Jonathan Daugherty for the patch. homepage: http://github.com/alpmestan/gloss-juicy license: BSD3 license-file: LICENSE
gloss-juicy.hs view
@@ -1,6 +1,5 @@ module Main where -import Codec.Picture import Graphics.Gloss import Graphics.Gloss.Juicy import System.Environment@@ -9,17 +8,9 @@ main = do args <- getArgs case args of - [filename] -> do- tryRead <- readImage filename- case tryRead of- Left err -> putStrLn ("error reading png file " ++ filename ++ ": " ++ err)- Right im -> tryConvert im-+ [filename] -> loadJuicy filename >>= maybe (putStrLn $ "Couldn't load or decode " ++ filename) displayPic _ -> putStrLn "usage: gloss-juicy <file> -- displays the image in a gloss window"- - where tryConvert img = case fromDynamicImage img of- Just p -> displayPic p- Nothing -> putStrLn "Couldn't convert"+ displayPic :: Picture -> IO () displayPic p@(Bitmap width height _ _) = display (InWindow "Image Viewer" (width, height) (10, 10))