Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #180 // b/w image compressor

Lua code

get("#178") -- PET font
get("#179") -- base64

l = math.ceil(#pixels/8)
t = {}
for i=1, l do
  local b, x = 0, 128
  for j=0, 7 do
    local p = pixels[i*8-7+j]
    if p ~= nil and p ~= 0 then
      b = b+x
    end
    x = x/2
  end
  if i <= 8 then print(b) end
  table.insert(t, string.char(b))
end
s = table.concat(t)
print("string length: "..tostring(#s))
compressed = encode64(s)
print("base64 length: "..tostring(#compressed))

code = "grab('#181') -- uncompressor\n"
code = code.."width, height = "..tostring(width)..", "..tostring(height).."\n"
code = code.."pixels = uncompress('"..compressed.."')"
print(code)

test run  test run with input  download  show line numbers   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Image recognition results

Recognizer Recognition Result Visualize Recalc
#308 644 [visualize]

Snippet ID: #180
Snippet name: b/w image compressor
Eternal ID of this version: #180/1
Text MD5: 9fe4d2ff057c8c2da954af123dae58db
Author: stefan
Category:
Type: Lua code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2014-01-16 04:25:27
Source code size: 644 bytes / 26 lines
Pitched / IR pitched: Yes / Yes
Views / Downloads: 863 / 229
Referenced in: [show references]