Skip to content

Instantly share code, notes, and snippets.

@fumieval
Created September 15, 2012 05:37
Show Gist options
  • Save fumieval/3726471 to your computer and use it in GitHub Desktop.
Save fumieval/3726471 to your computer and use it in GitHub Desktop.
Glossで任意の画像を読み込む
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