Aseprite

Aseprite

Arthur Mar 19, 2021 @ 7:20pm
Simple script to set your image or palette to 15-bit safe colors.
Hello! I made two simple scripts to set the RGB values of your images/palettes to a valid 15-bit color. This is useful if you are making homebrew for older consoles or just want to simulate them.
I made this one focusing on PS1 and N64 homebrew, so it does not apply to other consoles such as the SNES and Genesis. It should work for anything that uses 15-bit color, RGB 5:5:5 (5 bits per channel)

Here's the script to transform the palette values:
---------------------------------------------------------------------- -- Set palette 15-bit safe colors. ---------------------------------------------------------------------- local spr = app.activeSprite if not spr then return app.alert("There is no active sprite") end app.transaction( function() local pal = spr.palettes[1] for i = 0,#pal-1 do -- Modify each color of the palette by dividing it by -- 8 so it goes to 0 - 31 range, round it down and expand -- it back to 0 - 255 so that colors are displayed correctly. local ncolor = pal:getColor(i) pal:setColor(i, Color{ r=math.floor(ncolor.red/8)*8, g=math.floor(ncolor.green/8)*8, b=math.floor(ncolor.blue/8)*8 }) end end) app.refresh()

And this one is to set the whole image if you're using RGBA:

---------------------------------------------------------------------- -- Set the image pixels to a 15-bit safe value. -- -- It works for RGB/GRAY color modes. ---------------------------------------------------------------------- if app.apiVersion < 1 then return app.alert("This script requires Aseprite v1.2.10-beta3") end local cel = app.activeCel if not cel then return app.alert("There is no active image") end local img = cel.image:clone() if img.colorMode == ColorMode.RGB then local rgba = app.pixelColor.rgba local rgbaA = app.pixelColor.rgbaA for it in img:pixels() do local pixelValue = it() local redValue = math.floor(app.pixelColor.rgbaR(pixelValue)/8)*8 local greenValue = math.floor(app.pixelColor.rgbaG(pixelValue)/8)*8 local blueValue = math.floor(app.pixelColor.rgbaB(pixelValue)/8)*8 it(rgba(redValue, greenValue, blueValue, rgbaA(it()))) end elseif img.colorMode == ColorMode.GRAY then local graya = app.pixelColor.graya local grayaA = app.pixelColor.grayaA for it in img:pixels() do local pixelColor = it() local pixelValue = math.floor(app.pixelColor.grayaV(pixelColor)/8)*8 it(graya(pixelValue, grayaA(it()))) end end cel.image = img app.refresh()

I haven't tested this script properly yet, but the output is similar to what conversion tools will output, so it seems to match.
< >
Showing 1-3 of 3 comments
Sigmund Froid Mar 20, 2021 @ 9:12am 
Although I've no real idea what I'll do with that, it's really a nice thing to have just in case, thank you kind stranger!
should work for GBC and SNES as well!
yeetface513 Nov 18, 2023 @ 4:04am 
Originally posted by Sigmund Froid:
Although I've no real idea what I'll do with that, it's really a nice thing to have just in case, thank you kind stranger!
exactly
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Mar 19, 2021 @ 7:20pm
Posts: 3