Created
September 15, 2012 05:37
-
-
Save fumieval/3726471 to your computer and use it in GitHub Desktop.
Glossで任意の画像を読み込む
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.Gloss.Data.Picture | |
import Codec.Picture.Repa | |
import Data.Array.Repa as R hiding (map) | |
import qualified Data.Array.Repa.Repr.ForeignPtr as RF | |
loadImage :: FilePath -> IO Picture | |
loadImage path = do | |
img <- imgData <$> either error id <$> readImageRGBA path | |
let Z :. h :. w :. _ = R.extent img | |
return $! bitmapOfForeignPtr w h (RF.toForeignPtr $ flipVertically img) True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment