0

I want to have a GIF-image looping in the background of a game (For example with Gloss Juicy or module Codec.Picture.Gif)

Managed to work with a BMP image like this:

image :: IO Picture 
image = loadBMP "image.bmp"

But now I want to do the same with a GIF image:

loadGifFile :: FilePath -> IO Image 
loadGifFile = "image.gif"

Can't get it to work.

Thankful for any tip how to do it.

Will Ness
  • 70,110
  • 9
  • 98
  • 181
blobfish
  • 25
  • 3

1 Answers1

2

You are going to have to do some more work. loadBMP just loads a BMP file into a bitmap, which is a single image. However an animated GIF is a more complex file format which has several frames in it. GLOSS simply doesn't support that out of the box.

You could use JuicyPixels to decode a GIF file and then write some code to convert that into a list of GLOSS Bitmaps. Then use animate to draw those images in sequence.

Paul Johnson
  • 17,438
  • 3
  • 42
  • 59