Code: Select all
icon_path = "d:\\icon.png" -- png or jpg
function descriptor()
return {
title = "Icon image to Lua string",
icon = icon_string,
}
end
function activate()
Create_dialog()
end
function deactivate()
end
function meta_changed()
end
function close()
vlc.deactivate()
end
function Create_dialog()
d = vlc.dialog(descriptor().title)
text_input_path = d:add_text_input(icon_path,1,1,4,1)
d:add_button("Load icon", click_Load_icon, 1,2,1,1)
spin = d:add_spin_icon(2, 2, 1, 1)
html_Lua_string = d:add_html("Load PNG or JPG file (the smaller file, the shorter string). Recommended image resolution: 32x32. Then select and copy the resulting string.",1,3,4,1)
end
function click_Load_icon()
local file = io.open(text_input_path:get_text(), "rb")
if file==nil then
html_Lua_string:set_text("No file loaded! Check the path and try again.")
return false
end
-- Show progress
spin:animate()
d:update()
local data_string=""
while true do
data = file:read(1)
if data==nil or file:seek()>=50000 then break end
data_string=data_string.."\\"..string.byte(data)
vlc.keep_alive()
end
file:close()
html_Lua_string:set_text(data_string)
--
spin:stop()
end
icon_string = "\137\80\78\71\13\10\26\10\0\0\0\13\73\72\68\82\0\0\0\32\0\0\0\32\4\3\0\0\0\129\84\103\199\0\0\0\48\80\76\84\69\255\1\1\255\255\129\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\52\196\80\139\0\0\0\72\73\68\65\84\120\156\133\209\193\13\0\32\8\67\209\174\192\254\203\122\49\68\62\69\122\50\47\169\138\74\123\162\198\65\171\116\168\13\11\181\111\33\11\51\228\129\51\220\194\23\180\192\179\240\16\220\148\32\94\140\16\28\142\128\23\239\128\127\234\176\229\0\4\101\15\3\166\210\191\4\0\0\0\0\73\69\78\68\174\66\96\130"