Created
September 9, 2021 12:41
-
-
Save behreajj/627510ad0645ba88165215e21adc0fbe to your computer and use it in GitHub Desktop.
Ase Dialog Convert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dofile("./sRgbToAdobeRgb.lua") | |
local dlg = Dialog { title = "SRGB - Adobe Convert" } | |
dlg:button { | |
id = "palAdobeToSrgb", | |
text = "Pal &Adobe to sRGB", | |
onclick = function() | |
local sprite = app.activeSprite | |
if sprite then | |
local srcPal = sprite.palettes[1] | |
local trgPal = Palette(#srcPal) | |
for i = 0, #srcPal - 1, 1 do | |
local srcClr = srcPal:getColor(i) | |
if srcClr.alpha < 1 then | |
trgPal:setColor(i, Color(0, 0, 0, 0)) | |
else | |
local r, g, b = ColorConvert.AdobeRGB_to_sRGB( | |
srcClr.red, | |
srcClr.green, | |
srcClr.blue) | |
r = math.max(0, math.min(255, r)) | |
g = math.max(0, math.min(255, g)) | |
b = math.max(0, math.min(255, b)) | |
trgPal:setColor(i, Color(r, g, b, srcClr.alpha)) | |
end | |
end | |
sprite:setPalette(trgPal) | |
app.refresh() | |
end | |
end | |
} | |
dlg:newrow() | |
dlg:button { | |
id = "palSrgbToAdobe", | |
text = "Pal &sRGB to Adobe", | |
onclick = function() | |
local sprite = app.activeSprite | |
if sprite then | |
local srcPal = sprite.palettes[1] | |
local trgPal = Palette(#srcPal) | |
for i = 0, #srcPal - 1, 1 do | |
local srcClr = srcPal:getColor(i) | |
if srcClr.alpha < 1 then | |
trgPal:setColor(i, Color(0, 0, 0, 0)) | |
else | |
local r, g, b = ColorConvert.sRGB_to_AdobeRGB( | |
srcClr.red, | |
srcClr.green, | |
srcClr.blue) | |
r = math.max(0, math.min(255, r)) | |
g = math.max(0, math.min(255, g)) | |
b = math.max(0, math.min(255, b)) | |
trgPal:setColor(i, Color(r, g, b, srcClr.alpha)) | |
end | |
end | |
sprite:setPalette(trgPal) | |
app.refresh() | |
end | |
end | |
} | |
dlg:newrow() | |
dlg:button { | |
id = "cancel", | |
text = "&CANCEL", | |
onclick = function() | |
dlg:close() | |
end | |
} | |
dlg:show { wait = false } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment