├── README.md
├── doc
├── EXAMPLES.md
├── FILE_FORMAT.md
├── INSTALLATION.md
├── LICENSE
├── USAGE.md
└── examples
│ ├── bmp2ansi.lua
│ ├── gen_test_image.lua
│ └── images
│ ├── hello_world.bmp
│ ├── test_01.bmp
│ ├── test_02.bmp
│ └── test_03.bmp
├── lua-bitmap-0.0-1.rockspec
├── lua-bitmap-0.0-2.rockspec
├── lua-bitmap-0.0-3.rockspec
├── lua-bitmap-scm-1.rockspec
└── lua
└── lua-bitmap
├── init.lua
└── test_ints.lua
/README.md:
--------------------------------------------------------------------------------
1 | # lua-bitmap
2 |
3 | This single-file Lua-only library implements basic read/write support
4 | for a subset of the `Windows Bitmap`/`device-independent bitmap`
5 | file format, version 3.0.
6 |
7 | Compatible with Lua5.1, LuaJIT, Lua5.2, Lua5.3, Lua5.4.
8 |
9 |
10 |
11 | ## Supported file format
12 |
13 | `Windows Bitmap`/`device-independent bitmap`, version 3.0,
14 |
15 | * 24bpp/32bpp bitmaps only(no 1/2/4/8/16bpp)
16 | * no bitfields
17 | * no compression
18 |
19 | See [doc/FILE_FORMAT.md](doc/FILE_FORMAT.md)
20 |
21 |
22 | ## Library usage
23 |
24 | Library usage is documented in `doc/USAGE.md`.
25 |
26 | Example:
27 |
28 | ```
29 | local Bitmap = require("lua-bitmap") -- load module
30 | local bmp = Bitmap.empty_bitmap(width, height, alpha)
31 | --local bmp = Bitmap.from_string(data)
32 | --local bmp = Bitmap.from_file(path)
33 | --local bmp = Bitmap._new_bitmap()
34 | r,g,b,a = bmp:get_pixel(x,y) -- get color value at x,y
35 | bmp:set_pixel(x,y,r,g,b,a) -- set pixel at x,y to r,g,b,a[0-255]
36 | ```
37 |
38 | See [doc/USAGE.md](doc/USAGE.md)
39 |
40 |
41 |
42 | ## Installation
43 |
44 | The LuaRocks module is not published on a rocks server yet.
45 |
46 | See [doc/INSTALLATION.md](doc/INSTALLATION.md)
47 |
48 |
49 |
50 | ## Examples
51 |
52 | There are currently two runnable examples, `bmp2ansi.lua` coverts a
53 | bitmap to primitive ASCII art, and `gen_test_image.lua` generates a
54 | simple bitmap with a test pattern.
55 |
56 | bmp2ansi.lua: [doc/examples/bmp2ansi.lua](doc/examples/bmp2ansi.lua)
57 | gen_test_image.lua: [doc/examples/gen_test_image.lua](doc/examples/gen_test_image.lua)
58 |
59 | See [doc/EXAMPLES.md](doc/EXAMPLES.md)
60 |
--------------------------------------------------------------------------------
/doc/EXAMPLES.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | There are currently two runnable examples in the `doc/examples` directory:
4 |
5 |
6 |
7 | ## bmp2ansi.lua
8 |
9 | This example program uses the Bitmap library to read a BMP image
10 | from disk or stdin, then render it using very primitive ANSI art.
11 |
12 | Best use this on a terminal that supports 256-color ANSI escape sequences
13 | (most do, even when they only support 8/16 colors, like the Linux console).
14 |
15 | It optionally supports 24-bit ANSI color codes(most graphical terminal
16 | emulators work)
17 |
18 | ### Usage
19 |
20 | ```
21 | bmp2ansi.lua [--24bit]
22 | ```
23 |
24 | ### Example
25 |
26 | ```
27 | ./doc/examples/bmp2ansi.lua doc/examples/images/test_02.bmp --24bit
28 | ```
29 |
30 |
31 |
32 | ## gen_test_image.lua
33 |
34 | This script generates a test image, and saves it as a Bitmap file or to stdout.
35 |
36 | ### Usage
37 |
38 | ```
39 | gen_test_image.lua