Uploading new Color palette without replacing original palette

Hi community. I’m super new to Aseprite and have a quick question. I’m trying to add a layer to be my background with a new color pallet, but when I load the presets into my window it changes all the colors of my subject. How do I upload the preset color pallets in addition to the pallet that I already have for my subject? I hope this problem makes sense. Thank you to anyone who can help!

hi, short_past0! you need to switch from indexed to rgb. go to sprite → color mode → rgb color.

1 Like

Awesome! Thank you so much Olga_Galvanova!

1 Like

Hi @Short_Past0 ,

I wonder if a script would help with this part of your question

How do I upload the preset color pallets in addition to the pallet that I already have for my subject?

A dialog could concatenate two Palettes.

paletteDialog

local dlg = Dialog { title = "Concatenate Palettes" }

dlg:combobox {
    id = "aPalType",
    label = "Palette A:",
    option = "ACTIVE",
    options = { "ACTIVE", "FILE", "PRESET" },
    onchange = function()
        local state = dlg.data.aPalType

        dlg:modify {
            id = "aPalFile",
            visible = state == "FILE"
        }

        dlg:modify {
            id = "aPalPreset",
            visible = state == "PRESET"
        }
    end
}

dlg:file {
    id = "aPalFile",
    filetypes = { "gpl", "pal" },
    open = true,
    visible = false
}

dlg:entry {
    id = "aPalPreset",
    text = "...",
    focus = false,
    visible = false
}

dlg:newrow { always = false }

dlg:combobox {
    id = "bPalType",
    label = "Palette B:",
    option = "FILE",
    options = { "ACTIVE", "FILE", "PRESET" },
    onchange = function()
        local state = dlg.data.bPalType

        dlg:modify {
            id = "bPalFile",
            visible = state == "FILE"
        }

        dlg:modify {
            id = "bPalPreset",
            visible = state == "PRESET"
        }
    end
}

dlg:file {
    id = "bPalFile",
    filetypes = { "gpl", "pal" },
    open = true,
    visible = true
}

dlg:entry {
    id = "bPalPreset",
    text = "...",
    focus = false,
    visible = false
}

dlg:newrow { always = false }

dlg:check {
    id = "uniquesOnly",
    label = "Uniques Only:",
    selected = false
}

dlg:newrow { always = false }

dlg:separator()

dlg:label {
    id = "colorModeNotice",
    label = "WARNING:",
    text = "Set Color Mode to RGB before use."
}

dlg:newrow { always = false }

dlg:button {
    id = "cancel",
    text = "CANCEL",
    onclick = function()
        dlg:close()
    end
}

dlg:button {
    id = "ok",
    text = "OK",
    focus = true,
    onclick = function()

        local args = dlg.data
        if args.ok then
            local sprite = app.activeSprite
            if sprite then
                -- sprite.colorMode == 2 -- indexed.

                local aPal = nil
                local aPalType = args.aPalType
                if aPalType == "FILE" then
                    aPal = Palette { fromFile = args.aPalFile }
                elseif aPalType == "PRESET" then
                    aPal = Palette { fromResource = args.aPalPreset }
                else
                    aPal = sprite.palettes[1]
                end

                local bPal = nil
                local bPalType = args.bPalType
                if bPalType == "FILE" then
                    bPal = Palette { fromFile = args.bPalFile }
                elseif bPalType == "PRESET" then
                    bPal = Palette { fromResource = args.bPalPreset }
                else
                    bPal = sprite.palettes[1]
                end

                local cPal = nil
                local aLen = #aPal
                local bLen = #bPal

                if args.uniquesOnly then

                    local clrKeys = {}
                    local idx = 0

                    for i = 0, aLen - 1, 1 do
                        local hex = aPal:getColor(i).rgbaPixel
                        if not clrKeys[hex] then
                            idx = idx + 1
                            clrKeys[hex] = idx
                        end
                    end

                    for j = 0, bLen - 1, 1 do
                        local hex = bPal:getColor(j).rgbaPixel
                        if not clrKeys[hex] then
                            idx = idx + 1
                            clrKeys[hex] = idx
                        end
                    end

                    local clrVals = {}
                    for k, m in pairs(clrKeys) do
                        clrVals[m] = k
                    end

                    local cLen = #clrVals
                    cPal = Palette(cLen)
                    for m = 0, cLen - 1, 1 do
                        cPal:setColor(m, Color(clrVals[m + 1]))
                    end
                else
                    local cLen = aLen + bLen
                    cPal = Palette(cLen)

                    for i = 0, #aPal - 1, 1 do
                        cPal:setColor(i, aPal:getColor(i))
                    end

                    for j = 0, #bPal - 1, 1 do
                        local k = #aPal + j
                        cPal:setColor(k, bPal:getColor(j))
                    end
                end

                sprite:setPalette(cPal)
            else
                app.alert("No active sprite.")
            end
        end

    end
}

dlg:show { wait = false }

I kinda whipped this up in an afternoon, so I’m sure there are some significant cases it doesn’t cover. If you do try this out, Aseprite will issue a Security Warning when you click the OK button.

You may want to consider storing your palette(s) separately from the images if you have to do this for multiple layers. There’s a menu in Aseprite that looks like this

paletteSaveLoadOptions

which will give you some options (Save Palette, Save Palette as Preset). Some palette formats – like .gpl and .pal – are relatively easy to read. If the script option is a bit much to take in, you could combine palettes with a simple copy and paste in a text editor.

EDIT: You could also try New Palette From Sprite after combining the layers, but I didn’t recommend this bc IMO it doesn’t give me the results I want.

Hope that gives you some ideas!
Best,
Jeremy

thanks for this script, i always learn something new looking at your code.
just a quick note: you can copy and paste palettes directly in aseprite.

1 Like

@Olga_Galvanova ,

Thanks, I had no idea! That simplifies the matter dramatically!

How do I directly do this pasting?

you can create a selection by draggin directly in the color bar and then you can use usual ctrl + c, x or v.
just keep in mind to create and select new color swatch before pasting.

1 Like