Lots of fixes and cleanup

This commit is contained in:
Mathias Westerdahl
2018-05-11 12:42:35 +02:00
parent bda4987b52
commit db0fe0fbe4
19 changed files with 363 additions and 8259 deletions

View File

@@ -47,51 +47,12 @@ local function update_scan(self)
if text ~= nil then
msg.post("gui", "set_text", {text=text})
end_scan(self)
self.mode = "IDLE"
return
end
end
end
local function rescale_texture_old(src_buf, src_size, dst_buf, dst_size)
local src = buffer.get_stream(src_buf, hash("rgb"))
local dst = buffer.get_stream(dst_buf, hash("rgb"))
print("src", src_size, src_size, src_size*src_size*3)
print("dst", dst_size, dst_size, dst_size*dst_size*3)
for dy=0,dst_size-1 do
local v = dy / dst_size
for dx=0,dst_size-1 do
local u = dx / dst_size
local dst_index = (dy * dst_size + dx) * 3 + 1
local src_index = (math.floor(v * src_size) * src_size + math.floor(u * src_size)) * 3 + 1
print(dx, dy, dst_index, src_index)
dst[dst_index + 0] = src[src_index + 0]
dst[dst_index + 1] = src[src_index + 1]
dst[dst_index + 2] = src[src_index + 2]
end
end
end
local function rescale_texture(src_buf, src_size, dst_buf, dst_size)
local src = buffer.get_stream(src_buf, hash("rgb"))
local dst = buffer.get_stream(dst_buf, hash("rgb"))
print("src", src_size, src_size, src_size*src_size*3)
print("dst", dst_size, dst_size, dst_size*dst_size*3)
for dy=0,dst_size-1 do
local v = dy / dst_size
for dx=0,dst_size-1 do
local u = dx / dst_size
local dst_index = (dy * dst_size + dx) * 3 + 1
local src_index = (math.floor(v * src_size) * src_size + math.floor(u * src_size)) * 3 + 1
print(dx, dy, dst_index, src_index)
dst[dst_index + 0] = src[src_index + 0]
dst[dst_index + 1] = src[src_index + 1]
dst[dst_index + 2] = src[src_index + 2]
end
end
end
local function generate_qrcode(self, text)
local qrcode, qrsize = qrcode.generate(text)
@@ -128,7 +89,6 @@ function final(self)
end
function update(self, dt)
if self.mode == "SCAN" then
update_scan(self)
end

View File

@@ -1,29 +0,0 @@
function init(self)
-- Add initialization code here
-- Remove this function if not needed
end
function final(self)
-- Add finalization code here
-- Remove this function if not needed
end
function update(self, dt)
-- Add update code here
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Remove this function if not needed
end
function on_input(self, action_id, action)
-- Add input-handling code here
-- Remove this function if not needed
end
function on_reload(self)
-- Add reload-handling code here
-- Remove this function if not needed
end