Posted 14 January 2018 - 12:15 PM
Who said image storage has to be inefficient?
While it used to, I am here to change it!
RIF can store it all! Background color, text color and the character to draw!
RIF comes with 2 storage modes:
* compressed : Extremely efficient! 2 bytes per pixel + 2 bytes for metadata separators and enough bytes to write the x and y size as ASCII numbers! Use compress and uncompress methods to use this format
* table : Exported and loaded by the API. This one has the following size signature: 39 bytes for metadata, 8 bytes line overhead and 2 bytes per pixel also 6 byte trailer.
Now that is efficient!
But how to use the API, you may ask?
Its actually very easy!
The API provides 4 methods:
Methods in the Image object:
For storing in files, it is recommended to compress the exported data!
More example code as well as an image viewer coming soon.
COMPRESSION BUG FIXED!
While it used to, I am here to change it!
RIF can store it all! Background color, text color and the character to draw!
RIF comes with 2 storage modes:
* compressed : Extremely efficient! 2 bytes per pixel + 2 bytes for metadata separators and enough bytes to write the x and y size as ASCII numbers! Use compress and uncompress methods to use this format
* table : Exported and loaded by the API. This one has the following size signature: 39 bytes for metadata, 8 bytes line overhead and 2 bytes per pixel also 6 byte trailer.
Now that is efficient!
But how to use the API, you may ask?
Its actually very easy!
pastebin get tyrbiqRh rif.lua
And in your code,
os.loadAPI('rif.lua')
The API provides 4 methods:
image(x, y) : Returns Image object
load(uncompressedData) : Returns Image object
uncompress(compressedData) : Returns UncompressedData
compress(uncompressedData) : Returns CompressedData
Methods in the Image object:
place(x, y, character) : Returns Image object to allow call chaining
setTextColor(x, y, color) : Returns Image object to allow call chaining, note that the color has to be one from the colors API!
setBackgroundColor(x, y, color) : Returns Image object to allow call chaining, note that the color has to be one from the colors API!
export() : Returns uncompressedData
get(x, y) : Returns backgroundColor, textColor, character at the position. Colors in colors API format
getSize() : Returns x,y canvas size
For storing in files, it is recommended to compress the exported data!
More example code as well as an image viewer coming soon.
COMPRESSION BUG FIXED!
Edited on 14 January 2018 - 01:18 PM