Skip to content

stetre/moonimage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoonImage: Image Loading for Lua

MoonImage is a Lua image loading library based on Sean Barrett's STB libraries.

It runs on GNU/Linux and on Windows (MSYS2/MinGW) and requires Lua (>=5.3).

Author: Stefano Trettel

Lua logo

License

MIT/X11 license (same as Lua). See LICENSE.

Documentation

See the Reference Manual.

Getting and installing

Setup the build environment as described here, then:

$ git clone https://github.com/stetre/moonimage
$ cd moonimage
moonimage$ make
moonimage$ sudo make install

Example

The example below loads an image from a JPG file and writes it to a BMP file.

Other examples can be found in the examples/ directory contained in the release package.

-- MoonImage example: hello.lua
mi = require('moonimage')

-- Load an image from a jpg file:
data, w, h, channels = mi.load("sunflowers.jpg", 'rgba')

-- Write it to a bmp file:
mi.write_bmp("output.bmp", w, h, channels, data)

The script can be executed at the shell prompt with the standard Lua interpreter:

$ lua hello.lua

See also