diff options
author | ubq323 <ubq323@ubq323.website> | 2022-08-04 22:49:50 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2022-08-04 22:49:50 +0100 |
commit | 386e11ab576293f8eaec37bf792d1310fc0ea11c (patch) | |
tree | 79118f565a8fcff1355b8dc7caacd439ac6f57e3 /img | |
parent | 39b4e4f86c010ee84f5357e4490a6cfab49bedc9 (diff) |
load_pnm
Diffstat (limited to 'img')
-rw-r--r-- | img/load_pnm.lua | 2 | ||||
-rw-r--r-- | img/load_pnm_old.lua | 34 |
2 files changed, 1 insertions, 35 deletions
diff --git a/img/load_pnm.lua b/img/load_pnm.lua index d3f5873..1fd4b70 100644 --- a/img/load_pnm.lua +++ b/img/load_pnm.lua @@ -125,4 +125,4 @@ local function parse(imgf) return img end -return parse +return {load=parse} diff --git a/img/load_pnm_old.lua b/img/load_pnm_old.lua deleted file mode 100644 index 60cac8a..0000000 --- a/img/load_pnm_old.lua +++ /dev/null @@ -1,34 +0,0 @@ -local perr = require("util").perr - -local function load_p1(fname) - - local file,err = fs.open(fname,"r") - perr(err,"fs.open") - local imgf = file.readAll() - --print(img) - assert(imgf:sub(1,2) == "P1","only P1 images are supported at the moment") - local width,height, cur = imgf:match("%s*(%d+)%s*(%d+)%s*()",3) - assert(width,"couldn't find image header") - - local img=setmetatable({},{__index=function(t,k) - if type(k) ~= "number" then return nil end - local r = {} - rawset(t,k,r) - return r - end}) - - -- img[y][x]. 1,1 is top left - for row=1,height do - for col =1,width do - local val,ncur = imgf:match("(%d+)%s*()",cur) - cur = ncur - img[row][col] = tonumber(val) - end - end - - img.width=width - img.height=height - return img -end - -return load_p1 |