2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Glossで画像を読み込む

Last updated at Posted at 2012-09-24

要gloss, juicypixels-repa

glossLoadImage.hs

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

-- Data.Array.Repa.extractを用いて一部を切り抜くこともできる
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?