-
Notifications
You must be signed in to change notification settings - Fork 192
Image API
This library implements its own image format for OpenComputers with a simple loseless compression algorithm. It allows you to load and save pictures in .pic format, as well as to perform simple operations like string serialization/deserialization/scaling/transforming
Try to load an image from file system by given path. If loading was successful, the image table will be returned, it can be used for drawing on interface - for example, via GUI.image() method. If loading fails, false and reason will be returned. Reason describes why this happened - for example, the file system is read-only or there is not enough RAM to load image
local result, reason = image.load("test.pic")
if result then
-- Do your stuff like GUI.image(1, 1, result)
else
-- Image is broken or not enough RAM
endimage.save(string path, table picture, [, int encodingMethod = 6)]): boolean success, nil or string reason
Tries to save a given picture to a given path, using a specified encoding method.
If no encoding method is given, it will be set to 6 automatically.
Returns true if image was saved successfully, false and an reason if not (maybe filesystem is readonly or there's not enough disk space to save it)
local success, reason = image.load("test.pic")
if success then
-- Image was saved
else
-- Image wasn't saved because of "reason"
end