Skip to content

Lua library for handling BMP image files for FlashAir.

License

Notifications You must be signed in to change notification settings

AoiSaya/FlashAir-SlibBMP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

FlashAir-libBMP

Read and write 24bpp or 16bpp uncompressed windows bitmaps from pure Lua.

update at 2019/3/21:Suport 64K part load to save memory and direction(x,y) to udside down

Requirement

This is SoraMame library for BMP.
SoraMame series are IoT gadgets of FlashAir.

Tested on FlashAir W-04 v4.00.03.

Install

SlibBMP.lua -- Copy to somewhere in Lua's search path.

Color format of functions

bgcolor : BBBBB_GGGGGG_RRRRR (64K(16bpp) background color)

Internal bitmap data format

bitmap  = {}  
bitmap.header -- copyed from BMP header  
bitmap.width  -- bitmap width  
bitmap.height -- bitmap height  
bitmap.bit    -- bpp, 24 or 16(BBBBB_GGGGGG_RRRRR format)  
bitmap.flat   -- 1:Flat(Stuffing without leaving spaces for small image), 0:Stored in an array for each line.  
bitmap.data   -- bitmap data  

Usage

command description
bitmap,mes = BMP:loadFile(path, flat) Read content from file and return as bitmap
bitmap: bitmap table
mes: error message, if bitmap is nil

path: path+filename
flat: 1:data flat mode, 0:data array mode
res = BMP:saveFile(path, bitmap) Dump bitmap to file
res: "OK" or error message

path: path+filename
bitmap: bitmap table
img,mes = BMP:conv64K(bitmap or path) Convert 24bit bitmap to 16 bpp bitmap
If given path, read content from file.
img: 64K color bitmap table
mes: error message, if bitmap is nil

bitmap: bitmap table
path: path+filename
img,mes = BMP:conv64K(bitmap or path,
x, y, width, height, bgcolor)
Crop out the 24bpp bitmap and convert it to 16bpp bitmap
And replace the area out of the original image with the background color.
If given path, read content from file.
img: 64K color bitmap table
mes: error message, if bitmap is nil

bitmap: bitmap table
path: path+filename

Licence

MIT

Author

GitHub/AoiSaya
Twitter ID @La_zlo

About

Lua library for handling BMP image files for FlashAir.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages