From 4455347930947099fa2f67a9eb86d05ed5d08cf3 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 6 May 2020 01:14:34 -0700 Subject: [PATCH] Exporting luts now creates a job --- contrib/exportLUT.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/contrib/exportLUT.lua b/contrib/exportLUT.lua index da187f1..eaacf44 100644 --- a/contrib/exportLUT.lua +++ b/contrib/exportLUT.lua @@ -59,21 +59,38 @@ local warning_label = dt.new_widget("label"){ label = "WARNING: files may be silently overwritten" } +local function end_job(job) + job.valid = false +end + local function export_luts() - identity = dt.database.import(file_chooser_button.value) + local identity = dt.database.import(file_chooser_button.value) if(type(identity) ~= "userdata") then dt.print("Invalid identity lut file") else + local job = dt.gui.create_job('Exporting styles as haldCLUTs', true, end_job) + + local size = 1 + + for style_num, style in ipairs(dt.styles) do + size = size + 1 + end + + local count = 0 for style_num, style in ipairs(dt.styles) do identity:reset() dt.styles.apply(style, identity) - io_lut = dt.new_format("png") + local io_lut = dt.new_format("png") io_lut.bpp = 16 io_lut:write_image(identity, export_chooser_button.value .. os_path_seperator .. style.name .. ".png") + count = count + 1 + job.percent = count / size dt.print("Exported: " .. export_chooser_button.value .. os_path_seperator .. style.name .. ".png") end + dt.print("Done exporting haldCLUTs") + job.valid = false identity:reset() end end