项目作者: max1220

项目描述 :
Read Bitmap graphics in pure Lua.
高级语言: Lua
项目地址: git://github.com/max1220/lua-bitmap.git
创建时间: 2017-03-05T01:29:54Z
项目社区:https://github.com/max1220/lua-bitmap

开源协议:MIT License

下载


lua-bitmap

This single-file Lua-only library implements basic read/write support
for a subset of the Windows Bitmap/device-independent bitmap
file format, version 3.0.

Compatible with Lua5.1, LuaJIT, Lua5.2, Lua5.3, Lua5.4.

Supported file format

Windows Bitmap/device-independent bitmap, version 3.0,

  • 24bpp/32bpp bitmaps only(no 1/2/4/8/16bpp)
  • no bitfields
  • no compression

See doc/FILE_FORMAT.md

Library usage

Library usage is documented in doc/USAGE.md.

Example:

  1. local Bitmap = require("lua-bitmap") -- load module
  2. local bmp = Bitmap.empty_bitmap(width, height, alpha)
  3. --local bmp = Bitmap.from_string(data)
  4. --local bmp = Bitmap.from_file(path)
  5. --local bmp = Bitmap._new_bitmap()
  6. r,g,b,a = bmp:get_pixel(x,y) -- get color value at x,y
  7. bmp:set_pixel(x,y,r,g,b,a) -- set pixel at x,y to r,g,b,a[0-255]

See doc/USAGE.md

Installation

The LuaRocks module is not published on a rocks server yet.

See doc/INSTALLATION.md

Examples

There are currently two runnable examples, bmp2ansi.lua coverts a
bitmap to primitive ASCII art, and gen_test_image.lua generates a
simple bitmap with a test pattern.

bmp2ansi.lua: doc/examples/bmp2ansi.lua
gen_test_image.lua: doc/examples/gen_test_image.lua

See doc/EXAMPLES.md