Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fixPaintUtils()
- local tColourLookup = {}
- for n=1,16 do
- tColourLookup[ string.byte( "0123456789abcdef",n,n ) ] = 2^(n-1)
- end
- local function parseLine( tImageArg, sLine )
- local tLine = {}
- for x=1,sLine:len() do
- tLine[x] = tColourLookup[ string.byte(sLine,x,x) ] or 0
- end
- table.insert( tImageArg, tLine )
- end
- function paintutils.loadImage( sPath )
- if type( sPath ) ~= "string" then
- error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 )
- end
- if fs.exists( sPath ) then
- local file = io.open( sPath, "r" )
- local sContent = file:read("*a")
- file:close()
- return paintutils.parseImage( sContent ) -- delegate image parse to parseImage
- end
- return nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement