This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
lebuildman's profile picture

PaintUtils, Images and Tables

Started by lebuildman, 25 September 2014 - 11:42 PM
lebuildman #1
Posted 26 September 2014 - 01:42 AM
I'm trying to Create a Little Addon for PaintUtils to load Images Stored in Table (Paste the Paint File and Place lots of {"",} in it)
But I don't know Exatly What've todo in a Litte Part:
local tColourLookup = {}
for n=1,16 do
    tColourLookup[ string.byte( "0123456789abcdef",n,n ) ] = 2^(n-1)
end

function loadImageFromTable( imgTable )
    if type( imgTable ) ~= "table" then
        error( "Expected table", 2 )
    end

    local tImage = {}
		local i = 0
        repeat --[[ --Help Start Here--
            local tLine = {}
            for x=1,???? do
                tLine[x] = tColourLookup[ string.byte(sLine,x,x) ] or 0
            end
            table.insert( tImage, tLine )
            sLine = file:read() --Help Ends Here-- ]]--
        until i = #imgTable
        return tImage
    end
    return nil
end

How I Do That? Because I want to make some One-File Compressed Programs that have this Little Trouble Here…

Update:
The RAW Image Table Should look:
logoRAW = {
"99   9 11111 eeeee",
" 9   9 1   1 ee",
" 9   9 11111 eeeee",
" 9   9 1   1     e",
" 99999 1   1 eeeee"}
Edited on 25 September 2014 - 11:54 PM
Bomb Bloke #2
Posted 26 September 2014 - 02:34 AM
#imgTable gives you the number of entries in imgTable (that being the number of rows your image has, in this case). #imgTable[1] gives you the number of entries in the first table contained within imgTable (that being the number of columns your image has).