summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--img/shitty_disp.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/img/shitty_disp.lua b/img/shitty_disp.lua
index 3f060d9..625e646 100644
--- a/img/shitty_disp.lua
+++ b/img/shitty_disp.lua
@@ -73,13 +73,18 @@ local function median_cut(pxlist,remaining)
local hcount = math.floor(count/2)
local lhalf,uhalf = {},{}
- table.move(pxlist, 1,hcount, 1, lhalf)
- table.move(pxlist, hcount+1,count, 1, uhalf)
-
+ for i=1,hcount do
+ lhalf[i] = pxlist[i]
+ end
+ for i=hcount+1,count do
+ uhalf[i-hcount] = pxlist[i]
+ end
+
local lcols = median_cut(lhalf,remaining-1)
local ucols = median_cut(uhalf,remaining-1)
-
- return table.move(ucols,1,#ucols,#lcols+1,lcols)
+
+ for i=1,#ucols do table.insert(lcols,ucols[i]) end
+ return lcols
end
local function reset_palette(R)