DEV Community

ntop
ntop

Posted on

10 2

Write a GIF player with Golang

I just wrote a gif player with golang (less then 200 lines code). I use MAC a lot, but it can't play gif like windows, so this project come out.

It's a Golang project, also a korok project. The core code is little:

func main() {
    gfile := flag.Arg(0)
    // decode !
    gp, err := Load(gfile)
    if err != nil {
        log.Fatal(err)
    }
    w, h := gp.Size()
    options := korok.Options{
        Title: "Gif Player",
        Width:w,
        Height:h,
    }
    korok.Run(&options, &MainScene{p: gp})
}
Enter fullscreen mode Exit fullscreen mode

Gif decoding use Golong's gif module, the ui is setup with korok engine's GUI system. In fact, just one method is used:

gui.Image(1, m.img, nil)
Enter fullscreen mode Exit fullscreen mode

This API will draw a Texture at (0,0) of screen.

I have uploaded the project to Github: https://github.com/ntop001/xgif

About korok: it's component based 2d game engine in Golang, include a concise gui system. I use it to write some small tools. See: https://korok.io/

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay