PNGファイルがあり、Glossライブラリには。のBitmap
コンストラクタがありPicture
ます。ファイルタイプが原因で使用できないloadBMP :: FilePath -> IO Picture
ため、PNGファイルをロードしてBMPに変換し、、またはのいずれかにフィードする方法を探して bitmapOfBMP :: BMP -> Picture
いbitmapOfForeignPtr :: Int -> Int -> ForeignPtr Word8 -> Bool -> Picture
ますbitmapOfByteString :: Int -> Int -> ByteString -> Bool -> Picture
。
JuicyPixelsでテストする
import Data.ByteString as B
import System.IO as A
import Codec.Picture.Png
import Graphics.Gloss.Interface.Pure.Game
main = do
png <- B.readFile "samus.png"
let img = decodePng png
case img of
Left x -> A.putStrLn x
Right x -> do
let bmp = encodeDynamicPng x
case bmp of
Left x -> A.putStrLn x
Right x -> do
let pic = bitmapOfByteString 29 52 x True
game pic
game pic
= play
(InWindow "Test" (700, 500) (10, 10))
white
30
pic
draw
(const id)
(const id)
draw bmp
= bmp
すべてが成功しますが、イメージはまったく同じではありません。